html,
body {
  height: 100%;
  /* The board never scrolls as a page — panning happens on the canvas. Without
     this, DOM overlays (code cells, etc.) panned off-screen extend the document
     and the page becomes scrollable, so focusing a bubble editor would scroll
     those off-screen overlays into view. */
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  font-family: system-ui, sans-serif;
}

#app {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

#pixi-container canvas {
  display: block;
}

/* Top-left hamburger menu button */
.menu-button {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #dbe3ec;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(34, 51, 68, 0.18);
}

.menu-button:hover {
  background: #f3f7fb;
}

/* Settings modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 30, 42, 0.45);
}

/* A class with `display` overrides the default [hidden] rule, so restore it. */
.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(700px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(20, 30, 42, 0.35);
}

.modal-form {
  padding: 28px 32px 24px;
}

/* Tab bar + panels */
.modal-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 32px 0;
  border-bottom: 1px solid #e2e9f1;
}

.modal-tab {
  font-size: 14px;
  font-weight: 600;
  color: #7a8aa0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 10px 12px;
  margin-bottom: -1px;
  cursor: pointer;
}

.modal-tab:hover {
  color: #2b3a48;
}

.modal-tab[data-active="true"] {
  color: #2f6db0;
  border-bottom-color: #2f6db0;
}

.modal-panel {
  padding: 22px 32px 24px;
}

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

/* Boards list */
.board-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

/* Paged list: search + sort toolbar, rows, and a Prev/Next pager. */
.paged-list {
  margin-bottom: 20px;
}

.paged-list .board-list {
  margin-bottom: 0;
}

.paged-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.paged-toolbar[hidden] {
  display: none;
}

.paged-search {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.paged-search:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.paged-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 12px;
  color: #6b7a89;
}

.paged-sort select {
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1c2733;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.paged-sort select:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.paged-dir {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.paged-dir:hover {
  background: #f3f7fb;
}

.paged-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.paged-pager[hidden] {
  display: none;
}

.paged-nav {
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
}

.paged-nav:hover:not(:disabled) {
  background: #f3f7fb;
}

.paged-nav:disabled {
  color: #aab6c4;
  cursor: not-allowed;
}

.paged-page-label {
  font-size: 13px;
  color: #6b7a89;
  min-width: 92px;
  text-align: center;
}

.paged-empty {
  margin: 0;
  padding: 14px 4px;
  font-size: 14px;
  color: #7a8aa0;
  text-align: center;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e9f1;
  border-radius: 10px;
}

.board-row[data-current="true"] {
  border-color: #2f6db0;
  background: #f3f8fd;
}

.board-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: #2f6db0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-name:hover {
  text-decoration: underline;
}

.board-name:disabled {
  color: #1c2733;
  cursor: default;
  text-decoration: none;
}

.board-badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2f6db0;
  background: #dcebf9;
  border-radius: 999px;
  padding: 2px 8px;
}

/* Per-board cloud-sync control (checkbox + state label, S11). */
.board-sync {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5a6b7d;
  cursor: pointer;
  user-select: none;
}

.board-sync-box {
  flex: none;
  cursor: pointer;
  margin: 0;
}

.board-sync-state {
  white-space: nowrap;
}

.board-sync-state[data-state="synced"] {
  color: #2e7d46;
}

.board-sync-state[data-state="error"],
.board-sync-state[data-state="capped"] {
  color: #b3261e;
}

.board-sync-state[data-state="syncing"],
.board-sync-state[data-state="pending"] {
  color: #2f6db0;
}

.board-sync-state[data-state="paused"] {
  color: #9a6a00;
}

.board-row-actions {
  flex: none;
  display: flex;
  gap: 6px;
}

.board-action {
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
}

.board-action:hover {
  background: #f3f7fb;
}

.board-action:disabled {
  color: #aab6c4;
  cursor: not-allowed;
  background: #ffffff;
}

.board-delete:not(:disabled) {
  color: #b3261e;
  border-color: #e7c3c0;
}

.board-delete:not(:disabled):hover {
  background: #fdf1f0;
}

.new-board {
  display: flex;
  gap: 8px;
}

.new-board-input {
  box-sizing: border-box;
  flex: 1 1 auto;
  padding: 10px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.new-board-input:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.new-board-btn,
.import-board-btn {
  flex: none;
}

/* Signed-out boards on this device (Boards tab, "Copy to my account"). */
.local-boards {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid #e2e9f1;
}

.local-boards-heading {
  margin-bottom: 12px;
}

.board-name-local,
.board-name-local:hover {
  color: #1c2733;
  cursor: default;
  text-decoration: none;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 22px;
  color: #1c2733;
}

.modal-intro {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  color: #5a6b7d;
}

.modal-section {
  margin: 18px 0 12px;
  padding-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a8aa0;
  border-bottom: 1px solid #e2e9f1;
}

.modal-field {
  display: block;
  margin-bottom: 18px;
}

.modal-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
}

.modal-field input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.modal-field input:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

/* Generate-image modal: textarea + select fields and the settings row. */
.modal-field textarea,
.modal-field select {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
  background: #ffffff;
}

.modal-field textarea {
  resize: vertical;
  min-height: 60px;
}

.modal-field textarea:focus,
.modal-field select:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.imagegen-row {
  display: flex;
  gap: 12px;
}

.imagegen-row .modal-field {
  flex: 1 1 0;
  min-width: 0;
}

/* "Use different models" toggle + per-reply model dropdowns (hosted chat). */
.chat-diff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  cursor: pointer;
}

.chat-diff-row input {
  width: auto;
  margin: 0;
}

.chat-models {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.chat-model-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.chat-model-row span {
  margin-bottom: 0;
  flex: 0 0 auto;
  font-size: 12px;
  color: #6b7a89;
  white-space: nowrap;
}

.chat-model-row select {
  flex: 1 1 0;
  min-width: 0;
}

/* Compact per-reply temperature slider + its value readout. */
.chat-model-row .chat-temp-mini {
  flex: 0 0 76px;
  padding: 0;
  margin: 0;
}

.chat-model-row .chat-temp-mini-val {
  flex: 0 0 24px;
  font-size: 12px;
  font-weight: 600;
  color: #2b3a48;
  text-align: right;
}

/* Range slider (chat temperature) shouldn't get the text-input box chrome. */
.modal-field input[type="range"] {
  padding: 0;
  border: none;
  border-radius: 0;
  height: 22px;
  accent-color: #2f6db0;
  cursor: pointer;
}

.modal-field input[type="range"]:focus {
  box-shadow: none;
}

.chat-temp-val {
  color: #2f6db0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.modal-btn-secondary {
  background: #ffffff;
  border-color: #cdd9e6;
  color: #2b3a48;
}

.modal-btn-secondary:hover {
  background: #f3f7fb;
}

.modal-btn-primary {
  background: #2f6db0;
  color: #ffffff;
}

.modal-btn-primary:hover {
  background: #3a7ec6;
}

/* Magic-wand button in the HTML5 modal — pushed to the left of the actions row
   so it reads as a tool, not a confirm action. */
.modal-btn-wand {
  margin-right: auto;
  background: #7d4fb0;
  color: #ffffff;
}

.modal-btn-wand:hover:not(:disabled) {
  background: #8f5fc6;
}

.modal-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Pulse while the LLM reply streams into the editor (shares the cell's keyframes). */
.modal-btn-wand.is-busy {
  animation: code-cell-wand-pulse 1s ease-in-out infinite;
}

/* Drawing tool toolbar (fixed, top-center) */
.draw-toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  user-select: none;
}

.draw-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Thin divider between groups. */
.draw-group + .draw-group {
  padding-left: 10px;
  border-left: 1px solid #e2e9f1;
}

.draw-tool {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-tool:hover {
  background: #f3f7fb;
}

.draw-tool[data-active="true"] {
  background: #e6f0fb;
  border-color: #2f6db0;
}

.draw-color {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #cdd9e6;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* Trim the native swatch inset so the whole control reads as the chosen color. */
.draw-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.draw-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
.draw-color::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

.draw-width {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-width:hover {
  background: #f3f7fb;
}

.draw-width[data-active="true"] {
  background: #e6f0fb;
  border-color: #2f6db0;
}

.draw-width-dot {
  display: block;
  border-radius: 50%;
  background: #2b3a48;
}

.draw-action {
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  padding: 7px 12px;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-action:hover {
  background: #f3f7fb;
}

/* DOM context menu */
.context-menu {
  position: absolute;
  z-index: 1000;
  min-width: 160px;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  padding: 4px;
  user-select: none;
}

.context-menu-item {
  padding: 8px 12px;
  font-size: 14px;
  color: #223344;
  border-radius: 5px;
  cursor: pointer;
}

.context-menu-item:hover {
  background: #eef3f9;
}

/* Items that open a flyout get a trailing chevron. */
.context-menu-item.has-submenu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.context-menu-item.has-submenu::after {
  content: "▸";
  font-size: 12px;
  color: #7a8aa0;
}

/* Nested flyout menus are positioned in viewport coordinates. */
.context-submenu {
  position: fixed;
}

/* DOM overlay hosting the Filerobot image editor (active image bubble) */
.image-editor-overlay {
  position: absolute;
  z-index: 850;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(34, 51, 68, 0.3);
}

.image-editor-toolbar {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: #f3f7fb;
  border-bottom: 1px solid #e2e9f1;
}

.image-editor-export,
.image-editor-done {
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  padding: 7px 14px;
  cursor: pointer;
}

.image-editor-export {
  color: #2b3a48;
  background: #ffffff;
  border: 1px solid #cdd9e6;
}

.image-editor-export:hover {
  background: #eef4fa;
}

.image-editor-done {
  color: #ffffff;
  background: #2f6db0;
  border: 1px solid transparent;
}

.image-editor-done:hover {
  background: #3a7ec6;
}

.image-editor-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.image-editor-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 14px;
  color: #5a6b7d;
}

/* "Generating image…" placeholder overlay (anchored to a world point) */
.image-gen-loading {
  position: absolute;
  z-index: 850;
  transform-origin: top left;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 280px;
  padding: 12px 16px;
  font-size: 14px;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px dashed #b8c8da;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  user-select: none;
}

.image-gen-loading .loader {
  --size: 0.5px; /* 24px */
  flex: none;
}

.image-gen-loading.is-error {
  color: #c0392b;
  border-color: #e0a9a2;
  border-style: solid;
}

/* CSS orbit spinner: image generation + a chat bubble waiting for its answer. */
.loader {
  /* The pasted design used #fff for ring 1; our surfaces (white gen box, pale
     output bubble) are light, so a dark neutral keeps both rings visible. */
  --color-1: #263238;
  --color-2: #ff3d00;
  --size: 1px;

  display: inline-block;
  position: relative;
  transform: rotateZ(45deg);
  perspective: calc(1000 * var(--size));
  border-radius: 50%;
  width: calc(48 * var(--size));
  height: calc(48 * var(--size));
  color: var(--color-1);
}
.loader:before,
.loader:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: inherit;
  height: inherit;
  border-radius: 50%;
  transform: rotateX(70deg);
  animation: 1s loader-spin linear infinite;
}
.loader:after {
  color: var(--color-2);
  transform: rotateY(70deg);
  animation-delay: 0.4s;
}
@keyframes loader-spin {
  0%,
  100% {
    box-shadow: 0.2em 0 0 0 currentcolor;
  }
  12% {
    box-shadow: 0.2em 0.2em 0 0 currentcolor;
  }
  25% {
    box-shadow: 0 0.2em 0 0 currentcolor;
  }
  37% {
    box-shadow: -0.2em 0.2em 0 0 currentcolor;
  }
  50% {
    box-shadow: -0.2em 0 0 0 currentcolor;
  }
  62% {
    box-shadow: -0.2em -0.2em 0 0 currentcolor;
  }
  75% {
    box-shadow: 0 -0.2em 0 0 currentcolor;
  }
  87% {
    box-shadow: 0.2em -0.2em 0 0 currentcolor;
  }
}

/* Waiting spinner floated over an empty output bubble's blank placeholder box.
   The anchor sits at the bubble center (scaled by zoom); the inner wrapper
   translate(-50%,-50%)'s the loader off it so it stays centered at any scale. */
.bubble-spinner-anchor {
  position: absolute;
  z-index: 840;
  transform-origin: top left;
  pointer-events: none;
}
.bubble-spinner {
  position: absolute;
  transform: translate(-50%, -50%);
}
.bubble-spinner .loader {
  --size: 0.5px; /* 24px */
}

/* DOM code-cell overlay (Jupyter) */
.code-cell {
  position: absolute;
  z-index: 800;
  width: 520px;
  transform-origin: top left;
}

/* Drop-target feedback while dragging a "+" link onto another cell. */
.code-cell-link-ok .code-cell-body {
  border-color: #2f7d4f;
  box-shadow: 0 0 0 2px rgba(47, 125, 79, 0.45);
}

.code-cell-link-bad .code-cell-body {
  border-color: #c0392b;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.4);
}

.code-cell-body {
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  overflow: hidden;
}

/* Bottom-right corner grip for resizing, revealed on hover like the +/× badges.
   The diagonal stripes echo the native resize affordance. */
.code-cell-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  z-index: 3;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-bottom-right-radius: 10px;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    #9bb3cc 3px 4px
  );
}

.code-cell:hover .code-cell-resize {
  opacity: 0.85;
}

/* A corner-resized cell: the body is a fixed-height flex column so the editor
   and output share the space and scroll internally instead of auto-growing. */
.code-cell.is-sized .code-cell-body {
  display: flex;
  flex-direction: column;
}

.code-cell.is-sized .code-editor {
  /* flex-basis (the code's height) and flex-grow are set from JS so the editor
     hugs its typed code and the output flows beneath it, rather than the two
     splitting the box in half. */
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
}

.code-cell.is-sized .code-cell-editor {
  height: 100%;
  overflow: auto;
}

.code-cell.is-sized .code-cell-output {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
}

/* A sized markdown cell: whichever of the editor / rendered preview is shown
   fills the box and scrolls (only one is ever displayed at a time). */
.code-cell.is-sized .md-editor,
.code-cell.is-sized .md-rendered {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

/* The "+" spawner and "×" close badge only appear while the pointer is over
   the cell (matching the chat/image bubbles and the connector-link "×"). */
.code-cell-add,
.code-cell-close {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.code-cell:hover .code-cell-add,
.code-cell:hover .code-cell-close {
  opacity: 1;
  pointer-events: auto;
}

/* Orange "+" spawner straddling the lower-middle edge */
.code-cell-add {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
}

.code-cell-add:hover {
  background: #ff9f1a;
}

.code-cell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #f3f7fb;
  border-bottom: 1px solid #e2e9f1;
  cursor: grab;
  user-select: none;
}

.code-cell-header:active {
  cursor: grabbing;
}

.code-cell-count {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #7a8aa0;
  white-space: pre;
}

.code-cell-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #5a6b7d;
  letter-spacing: 0.02em;
}

/* Jupyter-style cell-type dropdown in the header (Code / Markdown). */
.code-cell-kind {
  font-size: 11px;
  font-weight: 600;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  padding: 2px 4px;
  cursor: pointer;
}

.code-cell-run {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 600;
  color: #ffffff;
  background: #2f7d4f;
  border: none;
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
}

.code-cell-run:disabled {
  opacity: 0.55;
  cursor: default;
}

.code-cell-stop {
  background: #c0392b;
  font-size: 10px;
  line-height: 1.4;
}

.code-cell-stop:hover {
  background: #d6463a;
}

.code-cell-runall {
  background: #2f6db0;
  letter-spacing: -1px;
}

.code-cell-runall:hover {
  background: #3a7ec6;
}

.code-cell-export {
  background: #5a6b7d;
}

.code-cell-export:hover {
  background: #6b7d90;
}

.code-cell-wand {
  background: #7d4fb0;
  padding: 3px 8px;
}

/* Vertical rule in the header separating the wand button from the run buttons
   on its left and the export/overflow buttons on its right. flex: none keeps the
   1px width from being shrunk away when the header is tight. */
.code-cell-sep {
  flex: none;
  width: 1px;
  height: 16px;
  background: #aebccb;
}

.code-cell-wand:hover:not(:disabled) {
  background: #8f5fc6;
}

/* Overflow "⋯" button (opens the dropdown of less-frequent actions). */
.code-cell-menu {
  background: #5a6b7d;
  padding: 3px 9px;
  line-height: 1;
}

.code-cell-menu:hover,
.code-cell-menu.is-open {
  background: #6b7d90;
}

/* Dropdown of overflow actions, anchored just under the header at the cell's
   right edge. Lives on `.code-cell` (not the clipped body) so it can overhang. */
.code-cell-menu-pop {
  position: absolute;
  top: 34px;
  right: 4px;
  z-index: 5;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
}

/* `display: flex` above would otherwise override the `hidden` attribute's
   UA `display: none` (equal specificity, later in source order), leaving the
   menu permanently visible. This guard re-hides it when closed. */
.code-cell-menu-pop[hidden] {
  display: none;
}

.code-cell-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: #3a4757;
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 6px 10px;
  white-space: nowrap;
  cursor: pointer;
}

.code-cell-menu-item:hover:not(:disabled) {
  background: #eef3f9;
}

.code-cell-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Pulse while the LLM reply is streaming into the editor. */
.code-cell-wand.is-busy {
  animation: code-cell-wand-pulse 1s ease-in-out infinite;
}

@keyframes code-cell-wand-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* Orange "×" badge straddling the top-right corner (matches chat/image bubbles) */
.code-cell-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
}

.code-cell-close:hover {
  background: #ff9f1a;
}

.code-cell-editor {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 64px;
  margin: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #1c2733;
  background: #ffffff;
  tab-size: 4;
}

/* Syntax-highlighted Python editor: a transparent textarea over a Prism <pre>.
   The two layers MUST share identical metrics (font, padding, wrapping) so the
   caret and the coloured text line up exactly. */
.code-editor {
  position: relative;
  /* Width of the line-number column; widened from JS once numbers need more
     digits. Both layers reserve it in padding-left so their text stays aligned. */
  --ce-gutter: 2ch;
}

.code-editor .ce-highlight,
.code-editor .code-cell-editor {
  box-sizing: border-box;
  padding: 12px 12px 12px calc(12px + var(--ce-gutter) + 8px);
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  tab-size: 4;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* One source line of the highlight layer. Block-level so a soft-wrapped line
   keeps a single number; min-height keeps empty lines one row tall (matching
   the textarea). The number renders in the gutter reserved by padding-left. */
.ce-line {
  display: block;
  position: relative;
  min-height: 1.5em;
}

.ce-line::before {
  content: attr(data-ln);
  position: absolute;
  left: calc(-1 * var(--ce-gutter) - 8px);
  width: var(--ce-gutter);
  text-align: right;
  color: #a8b6c6;
}

/* The highlight layer fills the box behind the textarea and ignores input. */
.code-editor .ce-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.code-editor .ce-highlight code {
  font: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
  word-break: inherit;
}

/* The textarea sits on top: invisible text, visible caret, so the coloured
   copy beneath shows through while the real editing happens here. */
.code-editor .code-cell-editor {
  position: relative;
  z-index: 1;
  width: 100%;
  background: transparent;
  color: transparent;
  caret-color: #1c2733;
  overflow: hidden;
}

/* Prism token colours (scoped to our highlight so no theme CSS is needed). */
.ce-highlight .token.comment,
.ce-highlight .token.prolog,
.ce-highlight .token.doctype,
.ce-highlight .token.cdata {
  color: #7a8aa0;
  font-style: italic;
}

.ce-highlight .token.string,
.ce-highlight .token.triple-quoted-string {
  color: #2f7d4f;
}

.ce-highlight .token.keyword {
  color: #8b5cf6;
}

.ce-highlight .token.boolean,
.ce-highlight .token.number {
  color: #c0631c;
}

.ce-highlight .token.builtin,
.ce-highlight .token.function {
  color: #2f6db0;
}

.ce-highlight .token.class-name,
.ce-highlight .token.decorator {
  color: #d99323;
}

.ce-highlight .token.operator,
.ce-highlight .token.punctuation {
  color: #5a6b7d;
}

/* Draggable divider between the editor and output. A thin bar with a centred
   grip; revealed (un-hidden from JS) once the cell has output. */
.code-cell-split {
  position: relative;
  height: 9px;
  flex: 0 0 auto;
  cursor: ns-resize;
  background: #f3f7fb;
  border-top: 1px solid #e2e9f1;
}

.code-cell-split::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: #cdd9e6;
}

.code-cell-split:hover {
  background: #e8eff6;
}

.code-cell-split:hover::after {
  background: #aebfd2;
}

.code-cell-output {
  padding: 10px 12px;
  background: #fafcfe;
  max-height: 320px;
  overflow: auto;
}

.code-cell-text {
  margin: 0;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #2b3a48;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-cell-text.is-error {
  color: #c0392b;
}

.code-cell-rich {
  display: block;
  max-width: 100%;
  margin: 6px 0;
}

.code-cell-rich img {
  max-width: 100%;
}

/* pandas DataFrame / rich HTML tables — mimic Jupyter's notebook DataFrame look
   (the `_repr_html_` markup is just a <table class="dataframe" border="1">, so
   without this it renders as the browser's default bare table). */
.code-cell-rich table {
  border: none;
  border-collapse: collapse;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #2b3a48;
  margin: 2px 0;
}

.code-cell-rich table th,
.code-cell-rich table td {
  border: none;
  padding: 3px 9px;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}

/* Column headers: bold, right-aligned, ruled off from the body (Jupyter style). */
.code-cell-rich table.dataframe thead th {
  font-weight: 600;
  border-bottom: 1px solid #c2cfdb;
}

/* Row-index labels down the left edge. */
.code-cell-rich table.dataframe tbody th {
  font-weight: 600;
  text-align: right;
}

/* Zebra striping + hover, like the classic notebook. */
.code-cell-rich table.dataframe tbody tr:nth-child(even) {
  background: #f4f7fa;
}

.code-cell-rich table.dataframe tbody tr:hover {
  background: #e9f1f8;
}

/* Markdown cell: a Jupyter markdown cell. The editor textarea and rendered
   preview swap via inline `display` from JS (only one is ever shown). */
.md-rendered {
  padding: 10px 14px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: #1c2733;
  word-break: break-word;
  cursor: text;
}

.md-rendered > :first-child {
  margin-top: 0;
}

.md-rendered > :last-child {
  margin-bottom: 0;
}

.md-rendered h1,
.md-rendered h2,
.md-rendered h3,
.md-rendered h4,
.md-rendered h5,
.md-rendered h6 {
  margin: 0.6em 0 0.3em;
  line-height: 1.25;
  font-weight: 700;
}

.md-rendered h1 {
  font-size: 1.6em;
}

.md-rendered h2 {
  font-size: 1.35em;
}

.md-rendered h3 {
  font-size: 1.15em;
}

.md-rendered p {
  margin: 0.5em 0;
}

.md-rendered ul,
.md-rendered ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.md-rendered code {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #eef3f9;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md-rendered pre.md-code {
  margin: 0.6em 0;
  padding: 10px 12px;
  background: #f3f7fb;
  border: 1px solid #e2e9f1;
  border-radius: 8px;
  overflow: auto;
}

.md-rendered pre.md-code code {
  background: none;
  padding: 0;
  white-space: pre;
}

/* Prism token colours for highlighted ```python fences (match the code cells). */
.md-rendered .token.comment {
  color: #7a8aa0;
  font-style: italic;
}

.md-rendered .token.string,
.md-rendered .token.triple-quoted-string {
  color: #2f7d4f;
}

.md-rendered .token.keyword {
  color: #8b5cf6;
}

.md-rendered .token.boolean,
.md-rendered .token.number {
  color: #c0631c;
}

.md-rendered .token.builtin,
.md-rendered .token.function {
  color: #2f6db0;
}

.md-rendered .token.class-name,
.md-rendered .token.decorator {
  color: #d99323;
}

.md-rendered .token.operator,
.md-rendered .token.punctuation {
  color: #5a6b7d;
}

.md-rendered blockquote {
  margin: 0.6em 0;
  padding: 0.2em 0.9em;
  border-left: 3px solid #cdd9e6;
  color: #5a6b7d;
}

.md-rendered a {
  color: #2f6db0;
}

.md-rendered hr {
  border: none;
  border-top: 1px solid #e2e9f1;
  margin: 0.8em 0;
}

.md-rendered img {
  max-width: 100%;
}

.md-rendered .md-empty {
  color: #9bb3cc;
  font-style: italic;
}

/* Kernel status pill (fixed, top-right) */
/* Presence avatar row (COLAB_SPEC Phase 4) — other members on this board. */
.presence-row {
  position: fixed;
  /* Sits below the kernel status pill (top: 12px) so they don't overlap. */
  top: 46px;
  right: 12px;
  z-index: 1101;
  display: flex;
  gap: 4px;
}

.presence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(34, 51, 68, 0.25);
  user-select: none;
}

.kernel-status {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1100;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: #7a8aa0;
  box-shadow: 0 2px 8px rgba(34, 51, 68, 0.2);
  user-select: none;
}

.kernel-status[data-status="loading"] {
  background: #d99323;
}

.kernel-status[data-status="ready"] {
  background: #2f7d4f;
}

.kernel-status[data-status="running"] {
  background: #2f6db0;
}

/* DOM textarea overlay used while editing a bubble */
.bubble-editor {
  position: absolute;
  z-index: 900;
  box-sizing: border-box;
  margin: 0;
  border: 1.5px solid #9bb3cc;
  border-radius: 12px;
  background: #ffffff;
  color: #223344;
  line-height: 20px;
  resize: none;
  overflow: hidden;
  outline: none;
  box-shadow: 0 4px 14px rgba(34, 51, 68, 0.15);
}

/* ===================================================================== */
/* Accounts & billing UI (BILLING_SPEC §11)                              */
/* ===================================================================== */

/* --- Account tab: signed-out CTA ------------------------------------- */
.account-signedout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.account-hint {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #5a6b7d;
}

.account-error {
  margin: 0;
  font-size: 14px;
  color: #b3261e;
}

/* --- Account tab: signed-in ----------------------------------------- */
.account-panel {
  display: flex;
  flex-direction: column;
}

.account-id {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-email {
  font-size: 15px;
  font-weight: 600;
  color: #1c2733;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-signout {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
}

.account-signout:hover {
  background: #f3f7fb;
}

.account-banner {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: #7a4a00;
  background: #fff6e6;
  border: 1px solid #f0d8a8;
  border-radius: 8px;
}

/* Balance pill */
.account-balance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.account-balance-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a8aa0;
}

.account-balance-pill {
  font-size: 20px;
  font-weight: 700;
  color: #1c6b3a;
  background: #e7f6ec;
  border: 1px solid #bfe6cd;
  border-radius: 999px;
  padding: 4px 16px;
}

.account-balance-pill[data-empty="true"] {
  color: #b3261e;
  background: #fdf1f0;
  border-color: #e7c3c0;
}

/* Top up */
.account-topup {
  margin-top: 6px;
}

.account-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.account-chip {
  font-size: 14px;
  font-weight: 600;
  color: #2f6db0;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}

.account-chip:hover {
  background: #f3f8fd;
  border-color: #2f6db0;
}

.account-topup-row {
  display: flex;
  gap: 8px;
}

.account-amount {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  background: #ffffff;
  color: #5a6b7d;
  font-size: 15px;
}

.account-amount:focus-within {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.account-amount-input {
  flex: 1 1 auto;
  border: none;
  outline: none;
  padding: 10px 0;
  font-size: 15px;
  color: #1c2733;
  background: transparent;
}

.account-topup-msg {
  margin: 8px 0 0;
  font-size: 13px;
  color: #1c6b3a;
}

.account-topup-msg[data-error="true"] {
  color: #b3261e;
}

/* Per-track mode toggle */
.account-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.account-mode-label {
  font-size: 14px;
  font-weight: 600;
  color: #2b3a48;
}

.account-seg {
  flex: none;
  display: flex;
  padding: 3px;
  background: #eef3f8;
  border-radius: 9px;
}

.account-seg-btn {
  font-size: 13px;
  font-weight: 600;
  color: #5a6b7d;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
}

.account-seg-btn[data-active="true"] {
  color: #1c2733;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(34, 51, 68, 0.15);
}

/* Hosted model picker */
.account-track {
  margin-bottom: 12px;
}

.account-track .account-mode {
  margin-bottom: 0;
}

.account-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
  padding-left: 2px;
}

.account-select {
  flex: 0 1 auto;
  max-width: 60%;
  padding: 7px 10px;
  font-size: 13px;
  color: #1c2733;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.account-select:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.account-picker-price {
  font-size: 12px;
  color: #7a8aa0;
}

/* Inline BYOK config fields (shown under a track set to "My own key") */
.account-byok {
  margin: 10px 0 2px;
}

.account-byok .modal-field {
  margin-bottom: 12px;
}

.account-byok-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.account-byok-actions .account-hint {
  margin: 0;
}

.account-saved {
  font-size: 13px;
  font-weight: 600;
  color: #1c6b3a;
}

/* Usage history */
.account-usage {
  display: flex;
  flex-direction: column;
  border: 1px solid #e2e9f1;
  border-radius: 10px;
  overflow: hidden;
}

.account-usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}

.account-usage-row + .account-usage-row {
  border-top: 1px solid #eef3f8;
}

.account-usage-row[data-status="failed"],
.account-usage-row[data-status="refunded"] {
  opacity: 0.6;
}

.account-usage-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-usage-model {
  font-size: 14px;
  font-weight: 600;
  color: #1c2733;
}

.account-usage-meta {
  font-size: 12px;
  color: #7a8aa0;
}

.account-usage-cost {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  color: #b3261e;
}

.account-usage-range {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.account-usage-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-usage-field span {
  font-size: 12px;
  font-weight: 600;
  color: #7a8aa0;
}

.account-usage-field input {
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border: 1px solid #e2e9f1;
  border-radius: 8px;
  color: #1c2733;
  background: #fff;
}

.account-usage-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: #1c2733;
}

.account-usage-total .account-usage-cost {
  font-size: 15px;
}

/* ===================================================================== */
/* Sign-in / sign-up page (BILLING_SPEC §8)                              */
/* ===================================================================== */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 30, 42, 0.55);
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  box-sizing: border-box;
  padding: 32px 32px 24px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(20, 30, 42, 0.4);
}

.auth-busy {
  opacity: 0.7;
  pointer-events: none;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 1;
  color: #7a8aa0;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.auth-close:hover {
  background: #f3f7fb;
  color: #2b3a48;
}

.auth-brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #2f6db0;
}

.auth-heading {
  margin: 6px 0 4px;
  font-size: 24px;
  color: #1c2733;
}

.auth-sub {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #5a6b7d;
}

.auth-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: #b3261e;
  background: #fdf1f0;
  border: 1px solid #e7c3c0;
  border-radius: 8px;
}

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #1c2733;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 10px;
  cursor: pointer;
}

.auth-google:hover {
  background: #f7fafd;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: #aab6c4;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: #e2e9f1;
}

.auth-field {
  display: block;
  margin-bottom: 14px;
}

.auth-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
}

.auth-field input {
  box-sizing: border-box;
  width: 100%;
  padding: 11px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.auth-field input:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 6px 0 18px;
  font-size: 13px;
  line-height: 1.5;
  color: #5a6b7d;
}

.auth-consent input {
  margin-top: 2px;
  flex: none;
}

.auth-policy-link {
  color: #2f6db0;
  text-decoration: underline;
  cursor: pointer;
}

.auth-submit {
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  background: #2f6db0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.auth-submit:hover {
  background: #3a7ec6;
}

.auth-switch {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: #5a6b7d;
}

.auth-link {
  font: inherit;
  font-weight: 600;
  color: #2f6db0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-forgot {
  display: block;
  margin: -6px 0 16px auto;
  font-size: 13px;
}

.auth-version {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11px;
  color: #aab6c4;
}

/* ===================================================================== */
/* Policy viewer overlay                                                 */
/* ===================================================================== */
.policy-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 30, 42, 0.55);
}

.policy-panel {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(20, 30, 42, 0.4);
}

.policy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e9f1;
}

.policy-title {
  margin: 0;
  font-size: 18px;
  color: #1c2733;
}

.policy-close {
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 1;
  color: #7a8aa0;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.policy-close:hover {
  background: #f3f7fb;
  color: #2b3a48;
}

.policy-body {
  padding: 20px 24px 28px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
  color: #2b3a48;
}

.policy-body h1 {
  font-size: 22px;
}

.policy-body h2 {
  font-size: 18px;
  margin-top: 24px;
}

.policy-body h3 {
  font-size: 15px;
  margin-top: 18px;
}

.policy-body a {
  color: #2f6db0;
}

.policy-body code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

/* --- Top-up return toast (M4 Stripe) ------------------------------------- */
.topup-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 420px);
  padding: 12px 14px;
  border-radius: 10px;
  background: #1c2733;
  color: #f4f7fb;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.topup-toast-spinner {
  flex: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #6fb0ff;
  border-radius: 50%;
  animation: topup-spin 0.7s linear infinite;
}

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

.topup-toast-action {
  flex: none;
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  background: #6fb0ff;
  color: #10243d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.topup-toast-action:hover {
  background: #8cc1ff;
}

.topup-toast-close {
  flex: none;
  margin-left: 4px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.topup-toast-close:hover {
  color: #ffffff;
}

/* ---- Univer editors (spreadsheet / rich-text doc) overlays ---- */
/* Mirrors the code-cell chrome: draggable header, resize grip, × close. The body
   has an explicit size so Univer's canvas can measure its container. */
.univer-cell {
  position: absolute;
  z-index: 800;
  transform-origin: top left;
}

.univer-cell-body {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  overflow: hidden;
}

/* Orange "+" on a spreadsheet's lower edge: click for a code cell that reads it,
   or drag onto a code cell to link it as a data source. Mirrors .code-cell-add,
   and like it only appears while the pointer is over the sheet. */
.univer-cell-add {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 1;
}

.univer-cell:hover .univer-cell-add {
  opacity: 1;
  pointer-events: auto;
}

.univer-cell-add:hover {
  background: #ff9f1a;
}

.univer-cell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #f3f7fb;
  border-bottom: 1px solid #e2e9f1;
  cursor: grab;
  user-select: none;
  flex: 0 0 auto;
}

.univer-cell-header:active {
  cursor: grabbing;
}

.univer-cell-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #5a6b7d;
  letter-spacing: 0.02em;
}

/* .xlsx import/export buttons in the spreadsheet header. */
.univer-cell-btn {
  font-size: 11px;
  font-weight: 600;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.univer-cell-btn:hover {
  background: #f3f7fb;
  border-color: #9bb3cc;
}

/* The Univer mount fills the remaining body height; Univer renders into it. */
.univer-cell-mount {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Orange "×" badge straddling the top-right corner (matches the other items). */
.univer-cell-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 3;
}

.univer-cell:hover .univer-cell-close {
  opacity: 1;
  pointer-events: auto;
}

.univer-cell-close:hover {
  background: #ff9f1a;
}

/* Bottom-right corner grip for resizing, revealed on hover (matches code cells). */
.univer-cell-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  z-index: 3;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-bottom-right-radius: 10px;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    #9bb3cc 3px 4px
  );
}

.univer-cell:hover .univer-cell-resize {
  opacity: 0.85;
}

/* ---- HTML5 bubble (sandboxed iframe in code-cell-style chrome) ---------- */
.html5-cell {
  position: absolute;
  z-index: 800;
  transform-origin: top left;
}

.html5-cell-body {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  overflow: hidden;
}

.html5-cell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #f3f7fb;
  border-bottom: 1px solid #e2e9f1;
  cursor: grab;
  user-select: none;
  flex: 0 0 auto;
}

.html5-cell-header:active {
  cursor: grabbing;
}

.html5-cell-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #5a6b7d;
  letter-spacing: 0.02em;
}

.html5-cell-btn {
  font-size: 11px;
  font-weight: 600;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.html5-cell-btn:hover {
  background: #f3f7fb;
  border-color: #9bb3cc;
}

/* The iframe fills the remaining body height and renders the user's markup. */
.html5-cell-frame {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0;
  background: #ffffff;
}

/* Orange "×" badge straddling the top-right corner (matches the other items). */
.html5-cell-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 3;
}

.html5-cell:hover .html5-cell-close {
  opacity: 1;
  pointer-events: auto;
}

.html5-cell-close:hover {
  background: #ff9f1a;
}

/* Bottom-right corner grip for resizing, revealed on hover (matches code cells). */
.html5-cell-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  z-index: 3;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-bottom-right-radius: 10px;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    #9bb3cc 3px 4px
  );
}

.html5-cell:hover .html5-cell-resize {
  opacity: 0.85;
}

/* Wider modal + monospace editor for the HTML5 authoring dialog. */
.modal-wide {
  width: min(760px, calc(100vw - 40px));
}

/* --- Free-text overlay ("Text" menu item): plain text straight on the board -- */
.board-text {
  position: absolute;
  z-index: 800;
  transform-origin: top left;
}

.board-text-content {
  box-sizing: border-box;
  padding: 2px 4px;
  min-width: 24px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.3;
  outline: 1px dashed transparent;
  border-radius: 4px;
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}

/* Faint outline on hover so an idle box is discoverable/grabbable. */
.board-text:hover .board-text-content {
  outline-color: rgba(90, 107, 125, 0.4);
}

/* Editing: solid ring, text caret, and text selection re-enabled. */
.board-text[data-editing="true"] .board-text-content {
  outline: 1.5px solid #4a90d9;
  background: rgba(255, 255, 255, 0.6);
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}

/* Placeholder while empty and not being edited. */
.board-text[data-empty="true"]:not([data-editing="true"]) .board-text-content::before {
  content: "Text";
  color: rgba(90, 107, 125, 0.5);
}

/* Floating styling toolbar, anchored just above the box while editing. */
.board-text-toolbar {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  white-space: nowrap;
  z-index: 5;
}

.board-text-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  background: none;
  cursor: pointer;
}

.board-text-select {
  font-size: 12px;
  color: #33475b;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  padding: 2px 4px;
  cursor: pointer;
}

.board-text-toggle {
  width: 24px;
  height: 24px;
  font-size: 13px;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
}

.board-text-toggle[data-active="true"] {
  background: #eaf2fb;
  border-color: #4a90d9;
  color: #23475b;
}

/* Orange "×" badge straddling the top-right corner (matches the other items). */
.board-text-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 6;
}

.board-text:hover .board-text-close {
  opacity: 1;
  pointer-events: auto;
}

.board-text-close:hover {
  background: #ff9f1a;
}

/* Bottom-right corner grip for resizing, revealed on hover. */
.board-text-resize {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 14px;
  height: 14px;
  z-index: 6;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    #9bb3cc 3px 4px
  );
}

.board-text:hover .board-text-resize,
.board-text[data-editing="true"] .board-text-resize {
  opacity: 0.85;
}

/* The editor row: a line-number gutter beside the textarea. The field frame
   (border, radius, focus ring) lives on this wrapper so the two read as one
   control; the textarea inside is stripped of its own. */
.html5-editor {
  display: flex;
  align-items: stretch;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.html5-editor:focus-within {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

/* Gutter metrics (font, line-height, vertical padding) must match the textarea
   so the numbers track its lines; scrollTop is synced from JS. */
.html5-gutter {
  margin: 0;
  padding: 10px 8px;
  min-width: 2ch;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
    monospace;
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
  color: #a8b6c6;
  background: #f3f7fb;
  border-right: 1px solid #e2e9f1;
  overflow: hidden;
  user-select: none;
}

.html5-editor .html5-source {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  resize: none;
}

.html5-editor .html5-source:focus {
  border: none;
  box-shadow: none;
}

.html5-source {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
    monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 2;
}

/* Inline magic-wand status / error line below the editor. */
.html5-wand-status {
  margin: 8px 0 0;
  font-size: 13px;
  color: #b4341f;
}

.html5-wand-status[hidden] {
  display: none;
}

/* --- collaboration sharing (COLAB_SPEC Phase 6) --------------------------- */

/* "Shared with me" section in the Boards tab (mirrors .local-boards). */
.shared-boards {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid #e2e9f1;
}

.shared-boards-heading {
  margin-bottom: 12px;
}

.board-badge-shared {
  color: #6b4bb0;
  background: #ece4fa;
  text-transform: none;
  letter-spacing: 0;
}

/* An owned board that *I* have shared with other members (settings board list). */
.board-badge-sharing {
  color: #2f7d4f;
  background: #dcf3e5;
}

/* Per-account synced-storage total against the 1 GB cap (Boards tab). */
.boards-total {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 2px 16px;
}
.boards-total-label {
  font-size: 12px;
  color: #5a6b7d;
  font-variant-numeric: tabular-nums;
}
.boards-total-bar {
  height: 6px;
  border-radius: 999px;
  background: #eef1f5;
  overflow: hidden;
}
.boards-total-fill {
  height: 100%;
  border-radius: 999px;
  background: #2f6db0;
  transition: width 0.2s ease;
}
.boards-total-fill[data-warn="true"] {
  background: #b0402f;
}

/* Stored size of a synced board (doc + images). Neutral until near the cap. */
.board-badge-size {
  color: #5a6b7d;
  background: #eef1f5;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.board-badge-size[data-warn="true"] {
  color: #b0402f;
  background: #fae4e0;
}

/* Share dialog (reuses .auth-card chrome, a touch wider + scrollable). */
.share-card {
  max-width: 460px;
  max-height: min(80vh, 640px);
  overflow-y: auto;
}

.share-invite-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 6px;
}

.share-email {
  box-sizing: border-box;
  flex: 1 1 auto;
  padding: 11px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.share-email:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.share-invite-row .auth-submit {
  width: auto;
  flex: none;
  padding: 11px 18px;
}

.share-secondary {
  width: 100%;
  margin-top: 10px;
}

.share-lists {
  margin-top: 8px;
}

.share-section {
  margin-top: 16px;
}

.share-section-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6b7d;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #eef2f7;
}

.share-row-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: #1c2733;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-role {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6b7d;
}

.share-remove {
  flex: none;
}

.share-note {
  margin: 6px 0 0;
}

.share-note-error {
  color: #b3261e;
}

/* Board-wide Ctrl/Cmd-drag marquee selection (select.ts). Screen-space overlays
   above the board content (z 900 > overlays' 800) so the frame can catch a drag
   that begins over a DOM overlay too. */
.board-marquee {
  position: fixed;
  z-index: 900;
  pointer-events: none;
  border: 1px solid #2f6db0;
  background: rgba(47, 109, 176, 0.1);
  border-radius: 2px;
}

.board-select-box {
  position: fixed;
  z-index: 900;
  cursor: move;
  border: 1.5px solid #2f6db0;
  background: rgba(47, 109, 176, 0.06);
  border-radius: 3px;
  touch-action: none;
}
