.startup-status {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  text-align: center;
}

.startup-status[hidden], #startup-retry[hidden] { display: none; }

#startup-retry {
  padding: 12px 20px;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  cursor: pointer;
}

#startup-retry:focus-visible { outline: 3px solid var(--ink-primary); outline-offset: 3px; }

:root {
  --bg-canvas: #f5f7fa;
  --surface-panel: rgba(255, 255, 255, 0.92);
  --surface-panel-solid: #ffffff;
  --surface-border: rgba(15, 23, 42, 0.11);
  --surface-border-subtle: rgba(15, 23, 42, 0.06);
  --surface-shadow: 0 8px 24px -6px rgba(15, 23, 42, 0.12), 0 2px 6px -1px rgba(15, 23, 42, 0.06);
  --surface-shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.16), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  --ink-primary: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #607086;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-active-ink: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-ink: #ffffff;
  --danger-ink: #b91c1c;
  --danger-bg: rgba(254, 242, 242, 0.96);
  --danger-border: rgba(220, 38, 38, 0.28);
  --hover-bg: rgba(15, 23, 42, 0.05);
  --active-bg: rgba(37, 99, 235, 0.14);
  --dialog-bg: #ffffff;
  --dialog-border: rgba(15, 23, 42, 0.12);
  --dialog-header-ink: #0f172a;
  --dialog-desc-ink: #607086;
  --input-bg: #ffffff;
  --input-border: rgba(15, 23, 42, 0.16);
  --input-ink: #0f172a;
  --focus-ring: 0 0 0 2px rgba(37, 99, 235, 0.40);
  --empty-hint-bg: rgba(255, 255, 255, 0.82);
  --empty-hint-border: rgba(100, 116, 139, 0.32);
  --kbd-bg: #ffffff;
  --kbd-border: rgba(15, 23, 42, 0.16);
  --kbd-ink: #0f172a;
  --status-saved-ink: #166534;
  --status-saved-bg: rgba(34, 197, 94, 0.12);
  --status-saved-border: rgba(22, 101, 52, 0.28);
  --status-conflict-ink: #b45309;
  --status-conflict-bg: rgba(245, 158, 11, 0.16);
  --status-conflict-border: rgba(245, 158, 11, 0.38);
  --badge-bg: rgba(15, 23, 42, 0.06);
  --badge-ink: #475569;
  --radius-panel: 12px;
  --radius-control: 8px;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-canvas: #121826;
    --surface-panel: rgba(24, 32, 47, 0.88);
    --surface-panel-solid: #18202f;
    --surface-border: rgba(255, 255, 255, 0.12);
    --surface-border-subtle: rgba(255, 255, 255, 0.07);
    --surface-shadow: 0 12px 32px -6px rgba(0, 0, 0, 0.55), 0 4px 12px -2px rgba(0, 0, 0, 0.35);
    --surface-shadow-lg: 0 24px 40px -10px rgba(0, 0, 0, 0.70), 0 10px 16px -4px rgba(0, 0, 0, 0.45);
    --ink-primary: #f1f5f9;
    --ink-secondary: #b0bfd0;
    --ink-muted: #8094ac;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-active-ink: #93c5fd;
    --accent-soft: rgba(96, 165, 250, 0.20);
    --accent-ink: #0f172a;
    --danger-ink: #fca5a5;
    --danger-bg: rgba(239, 68, 68, 0.16);
    --danger-border: rgba(239, 68, 68, 0.36);
    --hover-bg: rgba(255, 255, 255, 0.08);
    --active-bg: rgba(59, 130, 246, 0.26);
    --dialog-bg: #1e293b;
    --dialog-border: rgba(255, 255, 255, 0.14);
    --dialog-header-ink: #f8fafc;
    --dialog-desc-ink: #b0bfd0;
    --input-bg: #0f172a;
    --input-border: rgba(255, 255, 255, 0.16);
    --input-ink: #e2e8f0;
    --focus-ring: 0 0 0 2px rgba(96, 165, 250, 0.50);
    --empty-hint-bg: rgba(24, 32, 47, 0.86);
    --empty-hint-border: rgba(148, 163, 184, 0.22);
    --kbd-bg: #0f172a;
    --kbd-border: rgba(255, 255, 255, 0.18);
    --kbd-ink: #f1f5f9;
    --status-saved-ink: #4ade80;
    --status-saved-bg: rgba(34, 197, 94, 0.16);
    --status-saved-border: rgba(74, 222, 128, 0.34);
    --status-conflict-ink: #fbbf24;
    --status-conflict-bg: rgba(245, 158, 11, 0.22);
    --status-conflict-border: rgba(251, 191, 36, 0.40);
    --badge-bg: rgba(255, 255, 255, 0.08);
    --badge-ink: #b0bfd0;
  }
}

:root[data-theme="dark"] {
  --bg-canvas: #121826;
  --surface-panel: rgba(24, 32, 47, 0.88);
  --surface-panel-solid: #18202f;
  --surface-border: rgba(255, 255, 255, 0.12);
  --surface-border-subtle: rgba(255, 255, 255, 0.07);
  --surface-shadow: 0 12px 32px -6px rgba(0, 0, 0, 0.55), 0 4px 12px -2px rgba(0, 0, 0, 0.35);
  --surface-shadow-lg: 0 24px 40px -10px rgba(0, 0, 0, 0.70), 0 10px 16px -4px rgba(0, 0, 0, 0.45);
  --ink-primary: #f1f5f9;
  --ink-secondary: #b0bfd0;
  --ink-muted: #8094ac;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-active-ink: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.20);
  --accent-ink: #0f172a;
  --danger-ink: #fca5a5;
  --danger-bg: rgba(239, 68, 68, 0.16);
  --danger-border: rgba(239, 68, 68, 0.36);
  --hover-bg: rgba(255, 255, 255, 0.08);
  --active-bg: rgba(59, 130, 246, 0.26);
  --dialog-bg: #1e293b;
  --dialog-border: rgba(255, 255, 255, 0.14);
  --dialog-header-ink: #f8fafc;
  --dialog-desc-ink: #b0bfd0;
  --input-bg: #0f172a;
  --input-border: rgba(255, 255, 255, 0.16);
  --input-ink: #e2e8f0;
  --focus-ring: 0 0 0 2px rgba(96, 165, 250, 0.50);
  --empty-hint-bg: rgba(24, 32, 47, 0.86);
  --empty-hint-border: rgba(148, 163, 184, 0.22);
  --kbd-bg: #0f172a;
  --kbd-border: rgba(255, 255, 255, 0.18);
  --kbd-ink: #f1f5f9;
  --status-saved-ink: #4ade80;
  --status-saved-bg: rgba(34, 197, 94, 0.16);
  --status-saved-border: rgba(74, 222, 128, 0.34);
  --status-conflict-ink: #fbbf24;
  --status-conflict-bg: rgba(245, 158, 11, 0.22);
  --status-conflict-border: rgba(251, 191, 36, 0.40);
  --badge-bg: rgba(255, 255, 255, 0.08);
  --badge-ink: #b0bfd0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
}

.editor-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
  cursor: default;
}

.editor-canvas:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 5px var(--surface-panel-solid);
}

.app-shell[data-cursor="move"] .editor-canvas {
  cursor: move;
}

.app-shell[data-cursor="crosshair"] .editor-canvas {
  cursor: crosshair;
}

.app-shell[data-cursor="grab"] .editor-canvas {
  cursor: grab;
}

.app-shell[data-cursor="grabbing"] .editor-canvas {
  cursor: grabbing;
}

.app-shell[data-cursor="nwse-resize"] .editor-canvas {
  cursor: nwse-resize;
}

.app-shell[data-cursor="nesw-resize"] .editor-canvas {
  cursor: nesw-resize;
}

.app-shell[data-cursor="ns-resize"] .editor-canvas {
  cursor: ns-resize;
}

.app-shell[data-cursor="ew-resize"] .editor-canvas {
  cursor: ew-resize;
}

.app-shell[data-cursor="col-resize"] .editor-canvas {
  cursor: col-resize;
}

.app-shell[data-cursor="row-resize"] .editor-canvas {
  cursor: row-resize;
}

.app-shell[data-cursor="text"] .editor-canvas {
  cursor: text;
}

.hud-panel {
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--surface-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand-bar {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  pointer-events: auto;
}

.action-bar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px;
  pointer-events: auto;
}

.style-bar {
  position: fixed;
  top: 60px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  pointer-events: auto;
}

.style-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

#routing-mode-group[data-visible="false"],
#routing-mode-group[data-visible="false"] button,
#routing-mode-divider[data-visible="false"] {
  display: none;
}

.style-btn {
  height: 28px;
  width: 28px;
  min-width: 28px;
  padding: 0;
  font-size: 11.5px;
}

.style-btn svg {
  width: 14px;
  height: 14px;
}

.style-icon {
  display: inline-block;
  pointer-events: none;
}

.stroke-icon-s {
  width: 13px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}

.stroke-icon-m {
  width: 13px;
  height: 2.8px;
  background: currentColor;
  border-radius: 1.5px;
}

.stroke-icon-l {
  width: 13px;
  height: 4.5px;
  background: currentColor;
  border-radius: 2px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
}

.brand-badge {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.brand-divider,
.dock-divider {
  width: 1px;
  height: 18px;
  background: var(--surface-border);
  flex-shrink: 0;
}

.status-shapes {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

.status-save {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-control);
  line-height: 1.4;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.status-save[data-status="saved"] {
  color: var(--status-saved-ink);
  background: var(--status-saved-bg);
}

.status-save[data-status="unsaved"] {
  color: var(--ink-muted);
  background: transparent;
}

.status-save[data-status="save_failed"] {
  color: var(--danger-ink);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  cursor: pointer;
  font-weight: 600;
}

.status-save[data-status="save_failed"]:hover {
  text-decoration: underline;
}

.status-save[data-status="conflict"] {
  color: var(--status-conflict-ink);
  background: var(--status-conflict-bg);
  border: 1px solid var(--status-conflict-border);
  cursor: pointer;
  font-weight: 600;
}

.status-save[data-status="conflict"]:hover {
  text-decoration: underline;
}

.status-conflict-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  margin-left: 6px;
  border-radius: var(--radius-control);
  line-height: 1.4;
  color: var(--status-conflict-ink);
  background: var(--status-conflict-bg);
  border: 1px solid var(--status-conflict-border);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.status-conflict-btn[hidden] {
  display: none !important;
}

.status-conflict-btn:hover {
  filter: brightness(1.1);
}

.conflict-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.conflict-dialog-backdrop[hidden] {
  display: none !important;
}

.conflict-dialog-card {
  background: var(--dialog-bg);
  border: 1px solid var(--dialog-border);
  border-radius: 12px;
  padding: 20px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--surface-shadow-lg);
  color: var(--ink-primary);
  font-family: inherit;
}

.conflict-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.conflict-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--dialog-header-ink);
}

.conflict-close-btn {
  background: none;
  border: none;
  color: var(--ink-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.conflict-close-btn:hover {
  background: var(--hover-bg);
  color: var(--ink-primary);
}

.conflict-dialog-desc {
  font-size: 13px;
  color: var(--dialog-desc-ink);
  margin: 0 0 14px 0;
  line-height: 1.5;
}

.conflict-select-container {
  margin-bottom: 16px;
}

.conflict-select-list {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--input-ink);
  padding: 8px;
  font-size: 12px;
  font-family: monospace;
  outline: none;
}

.conflict-select-list option {
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.conflict-select-list option:checked {
  background: var(--accent);
  color: var(--accent-ink);
}

.conflict-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.conflict-primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
}

.conflict-primary-btn:hover {
  background: var(--accent-hover);
}

.conflict-secondary-btn {
  background: var(--hover-bg);
  color: var(--ink-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--surface-border);
  cursor: pointer;
}

.conflict-secondary-btn:hover {
  background: var(--surface-border);
  color: var(--ink-primary);
}

.mermaid-dialog-card {
  max-width: 600px;
}

.mermaid-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mermaid-file-label {
  font-size: 12px;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mermaid-code-area {
  width: 100%;
  box-sizing: border-box;
  background: var(--input-bg);
  color: var(--input-ink);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color 0.15s ease;
}

.mermaid-code-area:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.mermaid-status-box {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  border: 1px solid transparent;
}

.mermaid-status-box[data-tone="neutral"] {
  background: var(--badge-bg);
  color: var(--ink-secondary);
  border-color: var(--surface-border);
}

.mermaid-status-box[data-tone="success"] {
  background: var(--status-saved-bg);
  color: var(--status-saved-ink);
  border-color: var(--status-saved-border);
}

.mermaid-status-box[data-tone="error"] {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-border);
}

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


.toast-banner {
  position: fixed;
  top: 58px;
  left: 50%;
  z-index: 15;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  box-shadow: var(--surface-shadow);
  color: var(--ink-primary);
  font-size: 12.5px;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.toast-banner[data-tone="error"] {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-ink);
}

.toast-banner[data-visible="false"] {
  opacity: 0;
  visibility: hidden;
}

.text-editor-panel {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: auto;
  background: var(--surface-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--accent);
  box-shadow: var(--surface-shadow), 0 0 0 1px var(--accent-soft);
  border-radius: var(--radius-control);
  padding: 6px;
  min-width: 140px;
  max-width: min(540px, calc(100dvw - 32px));
  transition: box-shadow 0.15s ease;
}

.text-editor-panel[data-visible="false"] {
  display: none;
}

.text-editor-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  padding: 0 2px;
}

.text-editor-input {
  width: 100%;
  min-height: 44px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.35;
  resize: vertical;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.text-editor-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.text-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.text-editor-footer .tool-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11.5px;
}

.text-editor-primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
}

.text-editor-primary-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

.empty-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--empty-hint-bg);
  border: 1px dashed var(--empty-hint-border);
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.empty-hint[data-visible="false"] {
  opacity: 0;
  visibility: hidden;
}

.empty-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 4px;
  border: 1px solid var(--kbd-border);
  background: var(--kbd-bg);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--kbd-ink);
}

.tool-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
}

.tool-dock .tool-label {
  display: none;
}

.tool-dock .tool-btn {
  padding: 0 7px;
  gap: 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}

.action-btn {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.tool-btn:hover:not(:disabled) {
  background: var(--hover-bg);
  color: var(--ink-primary);
}

.tool-btn[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent-active-ink);
}

.tool-btn:disabled {
  opacity: 0.36;
  cursor: default;
}

.tool-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.shortcut-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-muted);
}

.tool-btn:hover:not(:disabled) .shortcut-hint {
  color: var(--ink-secondary);
}

.tool-btn[data-active="true"] .shortcut-hint {
  color: var(--accent-active-ink);
}

.tool-lock-btn .lock-shackle-closed {
  display: none;
}

.tool-lock-btn[data-active="true"] .lock-shackle-open {
  display: none;
}

.tool-lock-btn[data-active="true"] .lock-shackle-closed {
  display: inline;
}

.swatch-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms ease, border-color 100ms ease;
}

.swatch-btn:hover {
  transform: scale(1.08);
}

.swatch-btn[data-active="true"] {
  border-color: var(--ink-primary);
}

.swatch-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.swatch-cobalt .swatch-dot {
  background: #1d4ed8;
}

.swatch-slate .swatch-dot {
  background: #1e293b;
}

.swatch-emerald .swatch-dot {
  background: #047857;
}

.swatch-amber .swatch-dot {
  background: #b45309;
}

.swatch-coral .swatch-dot {
  background: #be123c;
}

.zoom-hud {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}

.zoom-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}

.zoom-btn:hover {
  background: var(--hover-bg);
  color: var(--ink-primary);
}

.zoom-readout {
  min-width: 54px;
  text-align: center;
}

@media (max-width: 1100px) {
  .action-bar .tool-label {
    display: none;
  }

  .zoom-hud {
    bottom: 68px;
    right: 14px;
  }
}

@media (max-width: 900px) {
  .brand-bar {
    top: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .action-bar {
    top: 54px;
    left: 10px;
    right: auto;
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .style-bar {
    top: 100px;
    left: 10px;
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .tool-dock {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
  }

  .zoom-hud {
    bottom: 66px;
    right: 10px;
    left: auto;
  }
}

@media (max-width: 660px) {
  .brand-bar {
    top: 8px;
    left: 8px;
    max-width: calc(100vw - 16px);
    padding: 5px 9px;
    gap: 6px;
  }

  .action-bar {
    top: 48px;
    left: 8px;
    right: auto;
    max-width: calc(100vw - 16px);
    padding: 4px;
    gap: 2px;
    row-gap: 3px;
  }

  .action-bar .action-btn {
    height: 28px;
    min-width: 28px;
    padding: 0 6px;
  }

  .theme-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
  }

  .style-bar {
    top: 122px;
    left: 8px;
    max-width: calc(100vw - 16px);
    padding: 4px;
    gap: 2px;
    row-gap: 3px;
  }

  .style-btn {
    width: 25px;
    height: 25px;
    min-width: 25px;
  }

  .tool-label,
  .shortcut-hint {
    display: none;
  }

  .tool-dock {
    bottom: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    max-width: calc(100vw - 16px);
    justify-content: center;
    gap: 3px;
    row-gap: 4px;
    padding: 4px;
  }

  .tool-dock .tool-btn {
    height: 30px;
    min-width: 30px;
    padding: 0 6px;
  }

  .swatch-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
  }

  .zoom-hud {
    bottom: 88px;
    right: 8px;
    left: auto;
    max-width: calc(100vw - 16px);
  }

  .toast-banner {
    max-width: calc(100vw - 16px);
    text-align: center;
  }

  .conflict-dialog-card {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding: 14px;
  }

  .mermaid-file-row,
  .conflict-dialog-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
}

.theme-selector {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-border-subtle);
  padding: 2px;
  border-radius: var(--radius-control);
}

.theme-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 6px;
  color: var(--ink-muted);
}

.theme-btn:hover:not(:disabled) {
  background: var(--hover-bg);
  color: var(--ink-primary);
}

.theme-btn[data-active="true"] {
  background: var(--surface-panel-solid);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.theme-btn svg {
  width: 14px;
  height: 14px;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

#action-wrap-node-label, #status-text-overflow { display: none; }
#status-text-overflow { max-width: 180px; font-size: 11px; }

/* One intrinsic stack keeps contextual dock wrapping clear of zoom targets. */
.bottom-controls {
  position: fixed;
  left: calc(8px + env(safe-area-inset-left, 0px) + var(--visual-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px) + var(--visual-right, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--visual-bottom, 0px));
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}
.bottom-controls > .tool-dock,
.bottom-controls > .zoom-hud {
  position: static;
  transform: none;
  width: max-content;
  max-width: 100%;
  pointer-events: auto;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.bottom-controls > .zoom-hud { align-self: flex-end; }
#status-text-overflow { display: none; max-width: 240px; white-space: normal; }
.text-editor-panel {
  width: min(360px, var(--editor-width, calc(100dvw - 32px)));
  max-width: var(--editor-width, calc(100dvw - 32px));
  min-width: 0;
  max-height: var(--editor-height, calc(100dvh - 32px));
  overflow: hidden;
}
.text-editor-input { height: 120px; min-height: 0; flex: 1 1 auto; overflow: auto; resize: none; }
.text-editor-header, .text-editor-footer { flex-shrink: 0; }

/* Below a useful canvas height, keep the existing tools reachable by scrolling
   their stack instead of allowing them to intercept the occupied top bars. */
@media (max-height: 400px) {
  .bottom-controls {
    max-height: max(0px, calc(100dvh - 208px - var(--visual-bottom, 0px)));
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
  }
}
