:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0d1422;
  --panel-2: #0a101b;
  --line: #1c2740;
  --text: #e2e8f0;
  --muted: #8795ad;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1100px 500px at 82% -10%, rgba(56, 189, 248, 0.09), transparent 60%),
    radial-gradient(900px 500px at 8% 110%, rgba(129, 140, 248, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  flex: 0 0 58px;
  height: 58px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.72);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #0b1020;
  background: linear-gradient(135deg, #7dd3fc, #818cf8);
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.28);
}

.brand-name {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand-tag {
  margin-left: 2px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(13, 20, 34, 0.7);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  animation: pulse 1.4s ease-in-out infinite;
}

.status[data-state="ready"] {
  color: #b6f4de;
  border-color: rgba(52, 211, 153, 0.3);
}

.status[data-state="ready"] .status-dot {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: none;
}

.status[data-state="error"] {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}

.status[data-state="error"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
  animation: none;
}

.status[data-state="warn"] {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.35);
}

.status[data-state="warn"] .status-dot {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.workspace {
  flex: 1;
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: minmax(370px, 41%) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(10, 16, 27, 0.78));
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 15px;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
  background: rgba(13, 20, 34, 0.55);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #334155;
}

.dot.red {
  background: #f87171;
}
.dot.amber {
  background: #fbbf24;
}
.dot.green {
  background: #34d399;
}

.file {
  margin-left: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}

.toggle input {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: #141f33;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 550;
  padding: 8px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition:
    background 0.14s ease,
    transform 0.08s ease,
    opacity 0.14s ease;
}

.btn:hover:not(:disabled) {
  background: #1b2a44;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #06111f;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.22);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5cc8fb, #7c7ef4);
}

.btn.ghost {
  background: rgba(20, 31, 51, 0.55);
}

.btn.ghost:hover:not(:disabled) {
  background: #1b2a44;
}

.btn.tiny {
  padding: 4px 8px;
  font-size: 11px;
}

.play {
  font-size: 10px;
  line-height: 1;
}

kbd {
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid rgba(6, 17, 31, 0.25);
  background: rgba(6, 17, 31, 0.16);
  opacity: 0.75;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#accountBtn {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.72);
}

.project-current {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.project-label {
  color: #64748b;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-name {
  max-width: 260px;
  overflow: hidden;
  color: #dbe6f5;
  font-family: var(--mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-state {
  padding: 2px 6px;
  border: 1px solid #1e2c45;
  border-radius: 999px;
  color: #64748b;
  font-size: 9.5px;
  white-space: nowrap;
}

.project-state.dirty {
  border-color: rgba(251, 191, 36, 0.32);
  color: var(--amber);
}

.project-state.saved {
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--green);
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a101b;
}

.auth-tab {
  flex: 1;
  padding: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}

.auth-tab.active {
  background: #17233a;
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-note {
  margin: 0;
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-forgot {
  align-self: flex-start;
  margin: -6px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: #7dd3fc;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
}

#accountUnverified {
  margin: 10px 0;
}

#accountUnverified p {
  margin: 0 0 6px;
}

#accountUnverified .auth-actions {
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.account-line {
  margin: 0 0 10px;
  font-size: 13px;
}

.role-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
  color: #7dd3fc;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0b1321;
}

.project-item-main {
  min-width: 0;
}

.project-item-name {
  overflow: hidden;
  color: #dbe6f5;
  font-family: var(--mono);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item-meta {
  margin-top: 4px;
  color: #64748b;
  font-size: 10.5px;
}

.project-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.share-badge {
  padding: 2px 6px;
  border: 1px solid #1e2c45;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.share-badge.pending {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.07);
  color: var(--amber);
}

.share-badge.rejected {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.07);
  color: #fca5a5;
}

.owner-label {
  color: #64748b;
  font-size: 10px;
}

.file-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 15, 26, 0.72);
}

.file-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.file-tabs::-webkit-scrollbar {
  display: none;
}

.file-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px 5px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  user-select: none;
}

.file-tab:hover {
  color: #cbd5e1;
  background: #111c2f;
}

.file-tab.active {
  color: #e2e8f0;
  border-color: #263650;
  background: #132039;
  box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.65);
}

.file-tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.file-tab-browser {
  position: sticky;
  right: 0;
  border: 1px dashed rgba(56, 189, 248, 0.3);
  background: #0b1220;
  color: #7dd3fc;
  box-shadow: -10px 0 12px rgba(5, 9, 16, 0.55);
}

.file-tab-browser.active {
  border-style: solid;
  background: #132039;
}

.file-tab-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-tab-badge {
  padding: 1px 3px;
  border: 1px solid rgba(251, 191, 36, 0.38);
  border-radius: 4px;
  color: var(--amber);
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tab-close {
  appearance: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
}

.file-tab:hover .tab-close,
.file-tab.active .tab-close {
  opacity: 1;
}

.tab-close:hover {
  background: #7f1d1d;
  color: #fff;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.add-file-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #0b1220;
}

.add-file-form .text-input {
  width: 170px;
}

.form-hint {
  color: #64748b;
  font-size: 11px;
}

.form-hint.error {
  color: #fca5a5;
}

.file-viewer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
}

.file-viewer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0b1321;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.file-viewer-item:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.06);
}

.file-viewer-item.active {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(56, 189, 248, 0.11);
}

.file-viewer-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-viewer-name strong {
  overflow: hidden;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-viewer-entry {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.file-viewer-meta {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.file-viewer-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.text-input {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #0a101b;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
}

.text-input::placeholder {
  color: #52627c;
}

.text-input:focus {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

.editor-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
  background: var(--panel-2);
}

.editor-wrap[hidden] {
  display: none;
}

.file-browser {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 4px;
  background: var(--panel-2);
}

.file-browser[hidden] {
  display: none;
}

.file-browser-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-browser-toolbar .text-input {
  flex: 1;
  min-width: 0;
}

.file-browser-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding-right: 2px;
}

.file-browser-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.editor-highlight,
#code,
.editor-measure {
  margin: 0;
  padding: 16px 18px 16px 64px;
  border: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  font-style: normal;
  line-height: 20px;
  letter-spacing: normal;
  word-spacing: normal;
  font-variant-ligatures: none;
  font-feature-settings: normal;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

.editor-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 52px;
  overflow: hidden;
  border-right: 1px solid rgba(28, 39, 64, 0.75);
  background: var(--panel-2);
  pointer-events: none;
  user-select: none;
}

.editor-line-numbers {
  padding: 16px 10px 16px 0;
  color: #46566e;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  text-align: right;
  white-space: pre;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  will-change: transform;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  background:
    linear-gradient(90deg, rgba(56, 189, 248, 0.035), transparent 90px),
    transparent;
  color: #dbe6f5;
}

.editor-wrap.syntax-ready .editor-highlight {
  visibility: visible;
}

#code {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  outline: none;
  background: transparent;
  color: #dbe6f5;
  -webkit-text-fill-color: currentColor;
  caret-color: var(--accent);
  overflow: auto;
}

.editor-wrap.syntax-ready #code {
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.editor-wrap.custom-caret #code {
  caret-color: transparent;
}

.editor-caret {
  position: absolute;
  z-index: 2;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 7px rgba(56, 189, 248, 0.45);
  pointer-events: none;
  display: none;
}

.editor-caret.visible {
  display: block;
  animation: editor-caret-blink 1.1s steps(1, end) infinite;
}

@keyframes editor-caret-blink {
  0%, 50% {
    opacity: 1;
  }
  50.01%, 100% {
    opacity: 0;
  }
}

#code::selection {
  background: rgba(56, 189, 248, 0.24);
}

.tok-keyword {
  color: #c792ea;
}

.tok-string {
  color: #a5d6a7;
}

.tok-number {
  color: #f78c6c;
}

.tok-comment {
  color: #5f708c;
}

.tok-builtin {
  color: #82aaff;
}

.tok-api {
  color: #7dd3fc;
}

.tok-function {
  color: #ffd580;
}

.tok-operator {
  color: #94a3b8;
}

.console-head {
  min-height: 34px;
  padding: 5px 12px 5px 15px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.console-head .file {
  font-size: 11px;
}

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

.console {
  height: 128px;
  overflow: auto;
  padding: 9px 15px 12px;
  background: #080d17;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
}

.log {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log.muted {
  color: #5f708c;
}

.log.ok {
  color: var(--green);
}

.log.warn {
  color: var(--amber);
}

.log.error {
  color: #fca5a5;
}

.log.stdout {
  color: #cbd5e1;
}

.canvas-panel {
  background:
    radial-gradient(650px 400px at 70% 18%, rgba(56, 189, 248, 0.06), transparent 65%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.62), rgba(8, 13, 23, 0.9));
}

.canvas-head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.coords {
  min-width: 118px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 13, 23, 0.6);
  color: #64748b;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.coords.active {
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}

.meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 13, 23, 0.6);
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 9px;
  background: #0b1020;
  touch-action: pan-y pinch-zoom;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.45),
    0 0 70px rgba(56, 189, 248, 0.05);
}

.code-shape-editor {
  pointer-events: none;
}

.code-shape-highlight {
  fill: none !important;
  stroke: #38bdf8 !important;
  stroke-width: 2.5 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.95 !important;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.55));
}

.code-shape-guides {
  pointer-events: none;
}

.code-shape-handle {
  cursor: grab;
  pointer-events: all;
  touch-action: none;
}

.code-shape-handle.dragging {
  cursor: grabbing;
}

.code-shape-handle-hit {
  fill: transparent;
  pointer-events: all;
}

.code-shape-handle-dot {
  fill: #38bdf8;
  stroke: #0b1020;
  stroke-width: 1.5;
  pointer-events: none;
}

.code-shape-handle.radius .code-shape-handle-dot {
  fill: #fbbf24;
}

.code-shape-handle.angle .code-shape-handle-dot {
  fill: #f472b6;
}

.color-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: rgba(8, 13, 23, 0.5);
}

.color-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #2b3b5a;
  border-radius: 8px;
  overflow: hidden;
  display: inline-flex;
  appearance: none;
  background: var(--swatch, #38bdf8);
  cursor: pointer;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.1);
}

.colour-current {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.colour-preview {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #38bdf8;
}

.colour-hex-field {
  flex: 1;
}

.colour-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.colour-slider {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.colour-slider input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
}

.colour-group {
  margin-top: 18px;
}

.colour-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.colour-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.colour-chip {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 7px;
  cursor: pointer;
}

.colour-chip:hover {
  transform: scale(1.06);
}

.colour-chip.active {
  outline: 2px solid #7dd3fc;
  outline-offset: 1px;
}

.colour-empty {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 11px;
}

.color-hex {
  min-width: 72px;
  padding: 4px 8px;
  border: 1px solid #182339;
  border-radius: 6px;
  background: #0c1422;
  color: #dbe6f5;
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.02em;
}

.btn.tiny.replace:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.42);
  background: rgba(56, 189, 248, 0.1);
  color: #7dd3fc;
}

.color-hint {
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  white-space: nowrap;
}

.color-hint.active {
  color: var(--accent);
}

.cheatsheet {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 14px 11px;
  border-top: 1px solid var(--line);
  background: rgba(8, 13, 23, 0.5);
}

.cheat-label {
  margin-right: 3px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.1em;
  color: #64748b;
}

.api-chip {
  appearance: none;
  padding: 4px 7px;
  border: 0;
  border-radius: 5px;
  background: #101a2c;
  color: #9db1cc;
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  cursor: pointer;
}

.api-chip:hover {
  background: #182741;
  color: #7dd3fc;
}

.api-chip:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.modal {
  width: min(720px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
}

#libraryDialog {
  width: min(920px, calc(100vw - 28px));
}

#colourDialog {
  width: min(480px, calc(100vw - 28px));
}

#galleryDialog {
  width: min(1120px, calc(100vw - 28px));
}

#apiDialog {
  width: min(980px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(2, 6, 14, 0.74);
  backdrop-filter: blur(5px);
}

.modal[open] {
  animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid #243650;
  border-radius: 14px;
  background:
    radial-gradient(700px 300px at 90% -20%, rgba(56, 189, 248, 0.07), transparent 65%),
    linear-gradient(180deg, #0f1829, #0a111d);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.58);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.modal-sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-sub strong {
  color: #dbe6f5;
  font-family: var(--mono);
  font-weight: 500;
}

.icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  background: #17233a;
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  overflow: auto;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: rgba(8, 13, 23, 0.45);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

.field > span {
  color: #7c8ca6;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field small {
  color: #64748b;
  font-size: 10.5px;
}

.field .text-input {
  width: 100%;
}

.warning-box {
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.06);
  color: #d6c58f;
  font-size: 11.5px;
  line-height: 1.55;
}

.form-status {
  min-height: 17px;
  color: var(--muted);
  font-size: 11.5px;
}

.form-status.error,
.library-status.error {
  color: #fca5a5;
}

.form-status.success {
  color: var(--green);
}

.library-body {
  gap: 12px;
}

.library-search {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.search-btn {
  min-height: 34px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-chip {
  appearance: none;
  padding: 3px 8px;
  border: 1px solid #1e2c45;
  border-radius: 999px;
  background: #0c1422;
  color: #9db1cc;
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}

.tag-chip:hover {
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.tag-chip.active {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
}

.tag-chip .count {
  margin-left: 4px;
  color: #5f708c;
  font-size: 9.5px;
}

.library-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 11.5px;
}

.api-section-title {
  color: #64748b;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.api-section-hint {
  color: #475569;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.api-playground {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.1fr);
  grid-template-areas:
    "preview controls"
    "code code";
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1321;
}

.api-playground-preview {
  grid-area: preview;
  min-width: 0;
}

.api-playground-preview .api-preview {
  border: 1px solid #162136;
  border-radius: 8px;
}

.api-playground-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  align-content: start;
  gap: 8px;
}

.api-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.api-control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: #7c8ca6;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.api-control-value {
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: none;
}

.api-control input[type="range"] {
  width: 100%;
  margin: 3px 0;
  accent-color: var(--accent);
}

.api-control select,
.api-control input[type="text"],
.api-control input[type="color"] {
  width: 100%;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid #1e2c45;
  border-radius: 5px;
  outline: none;
  background: #0a101b;
  color: #b6c6dd;
  font-family: var(--mono);
  font-size: 10.5px;
}

.api-control input[type="color"] {
  padding: 2px;
  cursor: pointer;
}

.api-playground-code {
  grid-area: code;
  max-height: 180px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid #162136;
  border-radius: 7px;
  background: #070c15;
  color: #b6c6dd;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.55;
  white-space: pre;
}

.api-args {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.api-arg {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1321;
}

.api-arg-name {
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 11.5px;
}

.api-arg-meta {
  margin-top: 4px;
  color: #64748b;
  font-family: var(--mono);
  font-size: 10px;
}

.api-arg-desc {
  margin-top: 5px;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.45;
}

.api-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.api-example {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1321;
}

.api-preview {
  display: block;
  width: 100%;
  aspect-ratio: 11 / 7;
  background: #0b1020;
  border-bottom: 1px solid var(--line);
}

.api-guide-line {
  stroke: rgba(148, 163, 184, 0.55);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  stroke-linecap: round;
}

.api-guide-arc {
  fill: none;
  stroke: rgba(148, 163, 184, 0.32);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.api-guide-point {
  fill: #0b1020;
  stroke: #fbbf24;
  stroke-width: 1.2;
}

.api-guide-point.anchor {
  fill: #f8fafc;
  stroke: #0b1020;
}

.api-guide-point.centre {
  fill: #0b1020;
  stroke: #f87171;
}

.api-guide-label {
  fill: #cbd5e1;
  stroke: #0b1020;
  stroke-width: 2;
  paint-order: stroke;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.api-example-caption {
  padding: 8px 10px 0;
  color: #94a3b8;
  font-size: 11px;
}

.api-example-code {
  display: block;
  width: 100%;
  min-height: 88px;
  max-height: 190px;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-top: 1px solid #162136;
  outline: none;
  resize: vertical;
  overflow: auto;
  background: #070c15;
  color: #b6c6dd;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre;
}

.api-example-code:focus {
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.api-example-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 10px 10px;
  border-top: 1px solid #162136;
  background: #0a111d;
}

.api-example-status {
  min-width: 0;
  max-width: 62%;
  margin-left: auto;
  overflow: hidden;
  color: #64748b;
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.api-example-status.ok {
  color: var(--green);
}

.api-example-status.error {
  color: #fca5a5;
}

.api-example-status.warn {
  color: var(--amber);
}

.menu-wrap {
  position: relative;
}

.menu-btn {
  gap: 6px;
}

.menu-caret {
  font-size: 9px;
  opacity: 0.7;
}

.app-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  padding: 5px;
  border: 1px solid #243650;
  border-radius: 10px;
  background: #0f1829;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.app-menu-item {
  display: block;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  font-family: var(--sans);
  font-size: 12px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.app-menu-item:hover,
.app-menu-item:focus-visible {
  background: #162136;
  color: #f8fafc;
  outline: none;
}

.app-menu-item[aria-current="page"] {
  color: #7dd3fc;
}

.tutorial-page {
  height: calc(100vh - 58px);
  overflow: auto;
  padding: 22px 20px 40px;
}

.tutorial-page-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.tutorial-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tutorial-page-head h1 {
  margin: 0 0 5px;
  color: #e2e8f0;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.tutorial-eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tutorial-page-head .modal-sub {
  max-width: 620px;
}

.tutorial-page-hint {
  max-width: 760px;
  margin: 8px 0 0;
  color: #7c8ca6;
  font-size: 11.5px;
  line-height: 1.5;
}

.tutorial-page-hint code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #111c2e;
  color: #bfe3ff;
  font-family: var(--mono);
  font-size: 0.92em;
}

.tutorial-page-head > .btn {
  flex-shrink: 0;
}

.tutorial-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
}

.workspace.tutorial-mode,
body[data-page="learn"] .workspace {
  grid-template-columns: 280px minmax(280px, 1fr) minmax(260px, 1fr);
}

.tutorial-panel {
  display: none;
  background:
    radial-gradient(420px 260px at 10% 0%, rgba(56, 189, 248, 0.07), transparent 65%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(10, 16, 27, 0.78));
}

body[data-page="learn"] .tutorial-panel {
  display: flex;
}

.tutorial-panel-head {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px 11px;
  border-bottom: 1px solid var(--line);
}

.tutorial-panel-head h1 {
  margin: 0;
  color: #e2e8f0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.tutorial-panel-sub {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.tutorial-panel-head .tutorial-page-hint {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
}

.tutorial-panel-back {
  align-self: flex-start;
  margin-top: 2px;
}

.tutorial-panel-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 14px;
  overflow: auto;
}

.tutorial-panel .tutorial-copy {
  gap: 9px;
}

.tutorial-status {
  min-height: 14px;
  color: #64748b;
  font-size: 10.5px;
  line-height: 1.4;
}

.tutorial-status.ok {
  color: var(--green);
}

.tutorial-status.error {
  color: #fca5a5;
}

.tutorial-status.warn {
  color: var(--amber);
}

.tutorial-steps {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: row;
  flex: 0 0 42px;
  gap: 4px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(28, 39, 64, 0.7);
  background: #0d1523;
}

.tutorial-step {
  appearance: none;
  display: flex;
  flex: 0 0 140px;
  align-items: flex-start;
  gap: 8px;
  width: 140px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8292aa;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.tutorial-step:hover {
  background: #101a2b;
  color: #dbe6f5;
}

.tutorial-step.active {
  border-color: rgba(56, 189, 248, 0.32);
  background: rgba(56, 189, 248, 0.08);
  color: #e2e8f0;
}

.tutorial-step-number {
  flex: 0 0 auto;
  min-width: 15px;
  color: #38bdf8;
  font-family: var(--mono);
  font-size: 10px;
}

.tutorial-step-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tutorial-main {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
  min-width: 0;
}

.tutorial-visual {
  display: flex;
  flex-direction: column;
  align-self: start;
  gap: 6px;
  min-width: 0;
}

.tutorial-preview-frame {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid #162136;
  border-radius: 9px;
  background: #070b18;
}

.tutorial-preview {
  display: block;
  width: 100%;
  height: 100%;
  background: #070b18;
}

.tutorial-preview-status {
  min-height: 15px;
  color: #64748b;
  font-size: 10.5px;
  line-height: 1.4;
}

.tutorial-preview-status.ok {
  color: var(--green);
}

.tutorial-preview-status.error {
  color: #fca5a5;
}

.tutorial-preview-status.warn {
  color: var(--amber);
}

.tutorial-copy {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.tutorial-step-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #64748b;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#tutorialConcept {
  color: #7dd3fc;
  text-transform: none;
}

.tutorial-copy h2 {
  margin: 0;
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.tutorial-text {
  color: #a8b6cb;
  font-size: 12px;
  line-height: 1.6;
}

.tutorial-text p {
  margin: 0 0 8px;
}

.tutorial-text p:last-child {
  margin-bottom: 0;
}

.tutorial-text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #111c2e;
  color: #bfe3ff;
  font-family: var(--mono);
  font-size: 0.92em;
}

.tutorial-text strong {
  color: #dbe6f5;
  font-weight: 600;
}

.tutorial-text .tutorial-tip {
  padding: 9px 10px;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.06);
  color: #bae6fd;
}

.tutorial-text .tutorial-tip strong {
  color: #e0f2fe;
}

.tutorial-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  color: #64748b;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tutorial-code {
  max-height: 240px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid #162136;
  border-radius: 8px;
  background: #070c15;
  color: #b6c6dd;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.55;
  white-space: pre;
  tab-size: 4;
}

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  padding-top: 2px;
}

.tutorial-actions #tutorialUse {
  margin-left: auto;
}

@media (max-width: 980px) {
  .tutorial-page {
    padding: 16px 14px 32px;
  }

  .tutorial-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 14px;
  }

  .tutorial-page-head {
    flex-wrap: wrap;
    margin-bottom: 14px;
  }

  .tutorial-steps {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(28, 39, 64, 0.7);
    background: #0d1523;
  }

  .tutorial-step {
    flex: 0 0 150px;
    width: 150px;
    min-height: 34px;
  }

  .tutorial-step-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .tutorial-main {
    grid-template-columns: 1fr;
  }

  .tutorial-visual {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
  }

  .tutorial-code {
    max-height: 220px;
  }
}

@media (max-width: 560px) {
  .tutorial-page {
    padding: 14px 10px 28px;
  }

  .tutorial-page-head h1 {
    font-size: 20px;
  }

  .tutorial-step {
    min-width: 130px;
  }

  .tutorial-actions #tutorialUse {
    margin-left: 0;
  }
}

.library-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0b1321;
}

.library-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 7px;
}

.library-item-title {
  color: #dbe6f5;
  font-family: var(--mono);
  font-size: 12.5px;
}

.library-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.library-item-date {
  color: #64748b;
  font-size: 10.5px;
}

.tag-pill {
  padding: 1px 5px;
  border: 1px solid #1e2c45;
  border-radius: 4px;
  background: #0c1422;
  color: #8fa6c4;
  font-family: var(--mono);
  font-size: 9.5px;
}

.library-item-body {
  padding: 0 12px 9px;
}

.library-code {
  max-height: 220px;
  margin: 0;
  padding: 9px 10px;
  overflow: auto;
  border: 1px solid #162136;
  border-radius: 7px;
  background: #070c15;
  color: #b6c6dd;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre;
}

.library-code.collapsed {
  max-height: 63px;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
}

.version-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #64748b;
  font-size: 10.5px;
  white-space: nowrap;
}

.version-select {
  max-width: 150px;
  padding: 3px 5px;
  border: 1px solid #1e2c45;
  border-radius: 5px;
  outline: none;
  background: #0a101b;
  color: #9db1cc;
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}

.version-select:disabled {
  opacity: 0.5;
}

.version-pill {
  border-color: rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
}

.file-count-pill {
  border-color: rgba(129, 140, 248, 0.35);
  color: #a5b4fc;
}

.library-bundle-hint {
  margin: 0 0 6px;
  color: #64748b;
  font-size: 10.5px;
}

.library-file-picker {
  margin: 0 0 6px;
}

.library-file-picker[hidden] {
  display: none;
}

.moderation-bundle-file {
  margin-top: 6px;
}

.moderation-bundle-file > summary {
  color: #9db1cc;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}

.moderation-bundle-file > .library-code {
  margin-top: 5px;
}

.library-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 10px;
}

.library-item-actions .spacer {
  flex: 1;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.gallery-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1321;
}

.gallery-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #0b1020;
  border-bottom: 1px solid var(--line);
}

.gallery-info {
  padding: 9px 11px 11px;
}

.gallery-title {
  color: #e2e8f0;
  font-size: 12.5px;
  font-weight: 600;
}

.gallery-meta {
  margin-top: 3px;
  color: #64748b;
  font-size: 10.5px;
}

.gallery-description {
  margin: 7px 0 0;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.45;
}

.empty-state {
  padding: 24px 12px;
  border: 1px dashed #223049;
  border-radius: 9px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  max-width: min(560px, calc(100vw - 24px));
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid #2a3a5c;
  border-radius: 9px;
  background: #0d1728;
  color: #dbe6f5;
  font-size: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}

.toast.warn {
  border-color: rgba(251, 191, 36, 0.4);
  color: #fde68a;
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.42);
  color: #fecaca;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #223049;
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #31415f;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
  }

  .workspace.tutorial-mode,
  body[data-page="learn"] .workspace {
    grid-template-columns: 1fr;
  }

  .tutorial-panel {
    height: 62vh;
    max-height: 62vh;
    min-height: 280px;
  }

  .tutorial-panel-head {
    flex: 0 0 auto;
  }

  .editor-panel {
    min-height: 68vh;
  }

  .canvas-panel {
    min-height: 62vh;
  }

  .canvas-wrap {
    padding: 12px;
  }

  .brand-tag {
    display: none;
  }

  .toggle {
    display: none;
  }

  .toggle.auto-draw {
    display: flex;
  }

  .file-bar {
    flex-wrap: wrap;
  }

  .file-tabs {
    flex-basis: 100%;
  }

  .file-actions {
    margin-left: auto;
  }

  .project-bar {
    flex-wrap: wrap;
  }

  .project-actions {
    margin-left: auto;
  }

  .library-search {
    grid-template-columns: 1fr;
  }

  .search-btn {
    width: 100%;
  }

  .modal-head,
  .modal-body,
  .modal-actions {
    padding-left: 14px;
    padding-right: 14px;
  }

  .api-playground {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "controls"
      "code";
  }
}

@media (max-width: 720px) {
  .topbar-right {
    gap: 4px;
  }

  .topbar-right .status {
    padding: 6px 8px;
  }

  .topbar-right .status #statusText {
    display: none;
  }

  .project-name {
    max-width: 150px;
  }

  .coords {
    min-width: 98px;
    font-size: 10px;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 8px;
    gap: 8px;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .editor-panel .panel-head {
    flex-wrap: wrap;
  }

  .editor-panel .panel-head .actions {
    width: 100%;
  }

  .brand-tag {
    display: none;
  }

  .add-file-form .text-input {
    flex: 1;
    min-width: 120px;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding: 0 12px;
  }

  .topbar-right {
    gap: 2px;
  }
}

.tutorial-text .tutorial-code-head {
  margin-top: 12px;
  margin-bottom: 4px;
}

.tutorial-text .tutorial-code {
  margin: 0 0 10px;
}


.learn-cta {
  background: rgba(56, 189, 248, 0.14);
  color: #d8f3ff;
  white-space: nowrap;
}

.learn-cta:hover {
  background: rgba(56, 189, 248, 0.24);
  color: #ffffff;
}

.learn-promo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(56, 189, 248, 0.11), rgba(167, 139, 250, 0.06) 60%, transparent);
}

.learn-promo-copy {
  min-width: 0;
}

.learn-promo-eyebrow {
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.learn-promo h1 {
  margin: 3px 0 4px;
  color: var(--text);
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.learn-promo p {
  max-width: 840px;
  margin: 0;
  color: #aebdd2;
  font-size: 11.5px;
  line-height: 1.55;
}

.learn-promo-actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.learn-promo-btn {
  padding: 8px 13px;
  font-size: 11.5px;
  white-space: nowrap;
}

.learn-promo-note {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8.5px;
  white-space: nowrap;
}

body[data-page="learn"] .learn-promo,
body[data-page="learn"] #headerLearn {
  display: none;
}

@media (max-width: 920px) {
  .learn-promo {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }
  .learn-promo-actions {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .learn-promo-note { white-space: normal; }
}

/* Static pages: gallery, blog, and shared shell */
body.page-shell {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

body.page-shell .topbar.site-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-topbar {
  gap: 16px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.site-nav a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: #7dd3fc;
}

.site-topbar > .btn {
  flex: none;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 34px 22px 64px;
}

.page-hero {
  max-width: 780px;
  margin: 0 0 30px;
}

.page-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-hero h1,
.post-head h1 {
  margin: 0 0 10px;
  color: #f1f5f9;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.page-lede {
  max-width: 720px;
  margin: 0;
  color: #aebdd2;
  font-size: 14px;
  line-height: 1.65;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.page-cta {
  margin-top: 34px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(129, 140, 248, 0.04));
}

.page-cta h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.page-cta p {
  max-width: 680px;
  margin: 0;
  color: #aebdd2;
  font-size: 13px;
  line-height: 1.6;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 20px;
  color: var(--dim);
  font-size: 11px;
}

.breadcrumb a {
  color: #7dd3fc;
  text-decoration: none;
}

.breadcrumb span {
  color: #4d5d76;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.blog-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1321;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.blog-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
  background: #0e1728;
}

.blog-card-meta {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.blog-card h2 {
  margin: 0;
  color: #e2e8f0;
  font-size: 17px;
  line-height: 1.25;
}

.blog-card p {
  margin: 0;
  color: #94a3b8;
  font-size: 12.5px;
  line-height: 1.55;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}

.tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 9px;
}

.post {
  max-width: 860px;
  margin: 0 auto;
}

.post-head {
  margin-bottom: 26px;
}

.post-body {
  color: #c6d4e8;
  font-size: 14px;
  line-height: 1.72;
}

.post-body h2 {
  margin: 30px 0 10px;
  color: #e2e8f0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.post-body h3 {
  margin: 22px 0 8px;
  color: #e2e8f0;
  font-size: 16px;
}

.post-body p {
  margin: 0 0 14px;
}

.post-body a {
  color: #7dd3fc;
}

.post-body ul,
.post-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.post-body li {
  margin: 5px 0;
}

.post-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #101a2c;
  color: #bfe3ff;
  font-family: var(--mono);
  font-size: 0.9em;
}

.post-body pre,
.gallery-code {
  margin: 0 0 18px;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #080e18;
  color: #c6d4e8;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  tab-size: 4;
}

.post-body pre code,
.gallery-code code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.post-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.post-footer h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.post-footer p {
  margin: 0;
  color: #aebdd2;
  font-size: 13px;
  line-height: 1.6;
}

.gallery-page-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.gallery-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.gallery-link:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
  background: #0e1728;
}

.gallery-detail {
  max-width: 920px;
  margin: 0 auto;
}

.gallery-detail-figure {
  margin: 24px 0;
}

.gallery-detail-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1020;
}

.gallery-byline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.gallery-files {
  color: var(--dim);
  font-size: 11.5px;
}

.gallery-files code {
  color: #bfe3ff;
}

.gallery-code-section {
  margin-top: 24px;
}

.gallery-code-section h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.gallery-code-section p {
  color: #aebdd2;
  font-size: 13px;
  line-height: 1.6;
}

.muted {
  color: var(--dim);
  font-size: 11.5px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px 22px 36px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
}

.site-footer strong {
  color: var(--text);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

@media (max-width: 760px) {
  .site-topbar {
    gap: 8px;
    padding: 0 12px;
  }

  .site-nav {
    gap: 10px;
  }

  .site-nav a {
    font-size: 11px;
  }

  .site-topbar > .btn {
    padding: 6px 9px;
    font-size: 11px;
  }

  .page {
    padding: 22px 14px 44px;
  }

  .page-hero h1,
  .post-head h1 {
    font-size: 28px;
  }

  .site-footer {
    padding: 18px 14px 30px;
  }
}

/* Shared/embed drawing mode */
body[data-page="embed"] {
  overflow: hidden;
}

body[data-page="embed"] .topbar,
body[data-page="embed"] .learn-promo,
body[data-page="embed"] .tutorial-panel,
body[data-page="embed"] .editor-panel,
body[data-page="embed"] .canvas-panel > .panel-head,
body[data-page="embed"] .canvas-panel > .color-bar,
body[data-page="embed"] .canvas-panel > .cheatsheet,
body[data-page="embed"] .toast {
  display: none !important;
}

body[data-page="embed"] .workspace {
  height: 100vh;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
}

body[data-page="embed"] .canvas-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #0b1020;
}

body[data-page="embed"] .canvas-wrap {
  padding: 0;
}

body[data-page="embed"] .canvas-wrap svg {
  width: 100%;
  height: 100%;
}

.embed-attribution {
  display: none;
}

body[data-page="embed"] .embed-attribution {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  display: block;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 11, 18, 0.82);
  color: #9db1cc;
  font-size: 10px;
  text-decoration: none;
}

body[data-page="embed"] .embed-attribution:hover {
  color: #e2e8f0;
}

#shareDrawingDialog textarea.text-input {
  min-height: 84px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
}

.learn-promo-links {
  display: inline-flex;
  gap: 6px;
  color: var(--dim);
  font-size: 9.5px;
}

.learn-promo-links a {
  color: #7dd3fc;
  text-decoration: none;
}

.learn-promo-links a:hover {
  color: #e2e8f0;
}

/* Shared drawing view page */
.view-actions {
  display: none;
}

body[data-page="view"] .view-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.82);
}

body[data-page="view"] .view-note {
  color: var(--dim);
  font-size: 11px;
}

body[data-page="view"] .view-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

body[data-page="view"] {
  overflow: hidden;
}

body[data-page="view"] .topbar,
body[data-page="view"] .learn-promo,
body[data-page="view"] .tutorial-panel,
body[data-page="view"] .editor-panel,
body[data-page="view"] .canvas-panel > .panel-head,
body[data-page="view"] .canvas-panel > .color-bar,
body[data-page="view"] .canvas-panel > .cheatsheet,
body[data-page="view"] .toast {
  display: none !important;
}

body[data-page="view"] .workspace {
  flex: 1;
  min-height: 0;
  height: auto;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
}

body[data-page="view"] .canvas-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #0b1020;
}

body[data-page="view"] .canvas-wrap {
  padding: 0;
}

body[data-page="view"] .canvas-wrap svg {
  width: 100%;
  height: 100%;
}

@media (max-width: 560px) {
  body[data-page="view"] .view-actions {
    padding: 8px 10px;
    gap: 6px;
  }

  body[data-page="view"] .view-note {
    display: none;
  }

  body[data-page="view"] .view-buttons {
    margin-left: 0;
  }
}

.canvas-head-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.canvas-size-btn {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.canvas-size-btn:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.06);
}

.canvas-size-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.privacy-table {
  width: 100%;
  margin: 12px 0 20px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.privacy-table th,
.privacy-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.privacy-table th {
  color: #e2e8f0;
  background: rgba(56, 189, 248, 0.06);
}

/* Desktop maximized code view */
body.editor-maximized .editor-panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  width: 100vw;
  height: 100vh;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: rgba(7, 11, 18, 0.2);
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
  box-shadow: none;
}

body.editor-maximized::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(0, 0, 0, 0.56);
  pointer-events: none;
}

body.editor-maximized .canvas-panel {
  position: relative;
  z-index: 1060;
  grid-column: 1 / -1;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.editor-maximized .canvas-panel > .panel-head,
body.editor-maximized .canvas-panel > .color-bar,
body.editor-maximized .canvas-panel > .cheatsheet {
  display: none !important;
}

body.editor-maximized .editor-panel .editor-wrap,
body.editor-maximized .editor-panel .editor-gutter,
body.editor-maximized .editor-panel .editor-highlight,
body.editor-maximized .editor-panel #code {
  background: transparent;
}

body.editor-maximized .editor-panel .console {
  background: rgba(6, 10, 18, 0.6);
}

body.editor-maximized .editor-panel .panel-head,
body.editor-maximized .editor-panel .project-bar,
body.editor-maximized .editor-panel .file-bar {
  background: rgba(10, 16, 28, 0.62);
}

body.editor-maximized .editor-panel .editor-highlight,
body.editor-maximized .editor-panel .editor-line-numbers {
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 6px rgba(0, 0, 0, 0.8);
}

body.editor-maximized .editor-panel .editor-wrap {
  background: transparent;
}

.editor-maximize {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 34px;
  padding: 0;
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 920px) {
  .editor-maximize {
    display: none !important;
  }
}
