:root {
  --font-interface: system-ui, "Segoe UI", sans-serif;
  --font-text: Georgia, Cambria, "Times New Roman", serif;
  --background-primary: #1f1f1f;
  --background-secondary: #252525;
  --background-secondary-alt: #2b2b2b;
  --background-canvas: #202020;
  --background-control: #1a1a1a;
  --workspace-bar-bg: #202020;
  --background-modifier-hover: #333333;
  --background-modifier-active: #3a3a3a;
  --background-modifier-border: #404040;
  --background-modifier-border-hover: #5a5a5a;
  --canvas-grid-small: rgba(255, 255, 255, 0.055);
  --canvas-grid-large: rgba(255, 255, 255, 0.09);
  --node-surface: rgba(43, 43, 43, 0.94);
  --node-border: rgba(255, 255, 255, 0.08);
  --visual-frame-surface: rgba(148, 154, 164, 0.16);
  --visual-frame-border: rgba(194, 200, 210, 0.28);
  --event-frame-surface: rgba(91, 64, 146, 0.44);
  --event-frame-border: rgba(184, 140, 255, 0.46);
  --frame-header-bg: rgba(255, 255, 255, 0.045);
  --subtle-button-border: rgba(255, 255, 255, 0.035);
  --subtle-button-bg: rgba(255, 255, 255, 0.025);
  --node-header-border: rgba(255, 255, 255, 0.065);
  --node-header-bg: rgba(255, 255, 255, 0.055);
  --overlay-bg: rgba(31, 31, 31, 0.9);
  --minimap-bg: rgba(25, 25, 25, 0.88);
  --scrollbar-track: rgba(255, 255, 255, 0.045);
  --scrollbar-thumb: rgba(255, 255, 255, 0.28);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.38);
  --link-color: rgba(220, 221, 222, 0.72);
  --text-normal: #dcddde;
  --text-muted: #a8a8a8;
  --text-faint: #7a7a7a;
  --text-on-accent: #ffffff;
  --interactive-accent: #7f6df2;
  --interactive-accent-hover: #9586ff;
  --accent-red: #e06c75;
  --focus-accent: var(--accent-red);
  --accent-orange: #d19a66;
  --accent-green: #98c379;
  --accent-cyan: #56b6c2;
  --accent-blue: #61afef;
  --radius-s: 4px;
  --radius-m: 6px;
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.32);
  color-scheme: dark;
}

:root[data-theme="light"],
.app-shell[data-theme="light"] {
  --background-primary: #f4f4f1;
  --background-secondary: #e9e7e2;
  --background-secondary-alt: #dedbd3;
  --background-canvas: #efeee9;
  --background-control: #ffffff;
  --workspace-bar-bg: #eceae5;
  --background-modifier-hover: #ddd9d1;
  --background-modifier-active: #d3cec3;
  --background-modifier-border: #c7c1b6;
  --background-modifier-border-hover: #aaa397;
  --canvas-grid-small: rgba(40, 37, 32, 0.085);
  --canvas-grid-large: rgba(40, 37, 32, 0.14);
  --node-surface: rgba(255, 255, 255, 0.94);
  --node-border: rgba(35, 31, 27, 0.14);
  --visual-frame-surface: rgba(52, 58, 68, 0.08);
  --visual-frame-border: rgba(52, 58, 68, 0.22);
  --event-frame-surface: rgba(118, 78, 190, 0.16);
  --event-frame-border: rgba(107, 75, 170, 0.36);
  --frame-header-bg: rgba(35, 31, 27, 0.035);
  --subtle-button-border: rgba(35, 31, 27, 0.08);
  --subtle-button-bg: rgba(35, 31, 27, 0.035);
  --node-header-border: rgba(35, 31, 27, 0.09);
  --node-header-bg: rgba(35, 31, 27, 0.045);
  --overlay-bg: rgba(255, 255, 255, 0.9);
  --minimap-bg: rgba(255, 255, 255, 0.78);
  --scrollbar-track: rgba(40, 37, 32, 0.08);
  --scrollbar-thumb: rgba(40, 37, 32, 0.32);
  --scrollbar-thumb-hover: rgba(40, 37, 32, 0.44);
  --link-color: rgba(55, 51, 45, 0.64);
  --text-normal: #171717;
  --text-muted: #3f3b35;
  --text-faint: #625b52;
  --text-on-accent: #ffffff;
  --interactive-accent: #6655dd;
  --interactive-accent-hover: #5343c5;
  --shadow-soft: 0 16px 36px rgba(40, 37, 32, 0.16);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  position: relative;
  overflow: hidden;
  background: var(--background-primary);
  color: var(--text-normal);
  font-family: var(--font-interface);
  font-size: 14px;
}

.startup-error {
  display: grid;
  align-content: center;
  gap: 10px;
  width: min(680px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  color: var(--text-normal);
}

.startup-error h1 {
  margin: 0;
  font-size: 22px;
}

.startup-error p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

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

button {
  color: inherit;
}

.app-shell {
  --sidebar-left-width: 280px;
  --sidebar-right-width: 340px;
  --sidebar-left-track: var(--sidebar-left-width);
  --sidebar-right-track: var(--sidebar-right-width);
  --sidebar-left-resizer-width: 6px;
  --sidebar-right-resizer-width: 6px;
  --sidebar-collapsed-width: 36px;
  --workspace-min-width: 420px;
  display: grid;
  grid-template-columns:
    var(--sidebar-left-track)
    var(--sidebar-left-resizer-width)
    minmax(var(--workspace-min-width), 1fr)
    var(--sidebar-right-resizer-width)
    var(--sidebar-right-track);
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--background-primary);
}

.app-shell[data-sidebar-left="collapsed"] {
  --sidebar-left-track: var(--sidebar-collapsed-width);
  --sidebar-left-resizer-width: 0px;
}

.app-shell[data-sidebar-right="collapsed"] {
  --sidebar-right-track: var(--sidebar-collapsed-width);
  --sidebar-right-resizer-width: 0px;
}

.app-shell.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

.app-shell.sidebar-resizing * {
  cursor: col-resize !important;
}

.icon-button,
.toolbar-button,
.inspector-tab,
.tree-item,
.palette-item,
.play-action,
.small-button {
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: transparent;
  cursor: pointer;
  transition: 140ms ease;
}

.toolbar-button:hover,
.icon-button:hover,
.small-button:hover,
.inspector-tab:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.sidebar {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding-bottom: 72px;
  border-right: 1px solid var(--background-modifier-border);
  background: var(--background-secondary);
}

.sidebar-resizer {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  cursor: col-resize;
  background: var(--background-primary);
}

.sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--background-modifier-border);
  transform: translateX(-50%);
  transition: background 140ms ease, width 140ms ease;
}

.sidebar-resizer:hover::before,
.app-shell[data-sidebar-resizing="left"] .sidebar-resizer-left::before,
.app-shell[data-sidebar-resizing="right"] .sidebar-resizer-right::before {
  width: 2px;
  background: var(--interactive-accent);
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-resizer-left,
.app-shell[data-sidebar-right="collapsed"] .sidebar-resizer-right {
  pointer-events: none;
}

.sidebar-right {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border-right: 0;
  border-left: 1px solid var(--background-modifier-border);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--background-modifier-border);
}

.pane-header > div:first-child {
  min-width: 0;
}

.pane-title {
  min-width: 0;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  margin-left: auto;
  gap: 6px;
}

.header-actions .icon-button {
  width: auto;
  min-width: 28px;
  padding: 0 8px;
  white-space: nowrap;
}

.sidebar-toggle-button {
  width: 28px;
  padding: 0;
}

.sidebar-toggle-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: currentColor;
  opacity: 0.9;
}

.sidebar-toggle-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 4px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.45;
}

.sidebar-toggle-icon-left::before {
  left: 2px;
}

.sidebar-toggle-icon-right::before {
  right: 2px;
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-toggle-icon-left::before {
  right: 2px;
  left: auto;
}

.app-shell[data-sidebar-right="collapsed"] .sidebar-toggle-icon-right::before {
  right: auto;
  left: 2px;
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-left,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right {
  overflow: hidden;
  padding-bottom: 0;
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-left .pane-header,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .pane-header {
  align-items: flex-start;
  justify-content: center;
  height: 100%;
  padding: 8px 4px;
  border-bottom: 0;
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-left .pane-title,
.app-shell[data-sidebar-left="collapsed"] .sidebar-left .nav-section,
.app-shell[data-sidebar-left="collapsed"] .sidebar-left .header-actions .icon-button:not(.sidebar-toggle-button),
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .pane-title,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .inspector-tabs,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .inspector-panel,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .header-actions .icon-button:not(.sidebar-toggle-button) {
  display: none;
}

.app-shell[data-sidebar-left="collapsed"] .sidebar-left .header-actions,
.app-shell[data-sidebar-right="collapsed"] .sidebar-right .header-actions {
  justify-content: center;
  margin: 0;
  gap: 0;
}

.pane-header.compact {
  height: 54px;
}

.pane-kicker {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pane-header h1,
.play-header h2 {
  margin: 2px 0 0;
  color: var(--text-normal);
  font-size: 15px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-color: var(--background-modifier-border);
  background: var(--background-secondary-alt);
}

.nav-section {
  padding: 14px 10px 0;
}

.nav-section h2 {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item,
.palette-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  text-align: left;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
}

.tree-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item:hover,
.tree-item.active,
.palette-item:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.file-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--interactive-accent);
}

.file-dot.muted {
  background: var(--text-faint);
}

.palette-list {
  display: grid;
  gap: 4px;
}

.palette-tools {
  display: flex;
  margin-bottom: 6px;
}

.palette-tools .small-button {
  width: 100%;
  min-width: 0;
}

.hidden-node-types {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--background-modifier-border);
}

.hidden-node-types summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-secondary-alt);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.hidden-node-types summary::-webkit-details-marker {
  display: none;
}

.hidden-node-types summary::before {
  content: "+";
  margin-right: 6px;
  color: var(--text-faint);
}

.hidden-node-types[open] summary::before {
  content: "-";
}

.hidden-node-types[data-empty="true"] summary {
  color: var(--text-faint);
}

.hidden-node-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--background-control);
  color: var(--text-muted);
  font-size: 11px;
}

.hidden-node-list {
  display: grid;
  gap: 4px;
  padding-top: 4px;
}

.hidden-node-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px 48px;
  align-items: center;
  gap: 6px;
}

.hidden-node-badge {
  cursor: default;
}

.restore-node-type-button {
  width: 48px;
  padding: 0;
  font-size: 12px;
}

.palette-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px 28px 28px;
  align-items: center;
  gap: 6px;
}

.palette-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-settings-button,
.palette-hide-button,
.palette-delete-button {
  width: 28px;
  height: 30px;
}

.palette-badge {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--node-color);
  color: #101010;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  word-break: keep-all;
  cursor: pointer;
}

.palette-badge[data-icon-size="double"] {
  font-size: 10px;
}

.palette-badge[data-icon-size="wide"] {
  font-size: 8px;
}

.palette-badge:hover,
.palette-badge:focus-visible {
  outline: 1px solid var(--focus-accent);
  outline-offset: 2px;
}

.custom-node-form {
  display: grid;
  gap: 8px;
}

.custom-node-form input,
.custom-node-form select {
  min-width: 0;
}

.custom-node-form select,
.custom-node-fields {
  width: 100%;
}

.custom-node-fields {
  min-height: 70px;
  resize: vertical;
}

.node-type-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--background-modifier-border);
}

.custom-node-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px auto;
  align-items: stretch;
  gap: 6px;
}

.custom-node-row input[type="color"] {
  width: 34px;
  min-width: 34px;
  height: 100%;
  padding: 3px;
}

.custom-node-row .small-button {
  height: auto;
  padding: 0 8px;
}

.custom-node-empty {
  color: var(--text-faint);
  font-size: 12px;
}

.canvas-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 36px;
  align-content: stretch;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--background-primary);
}

.app-shell[data-active-file="characters"] .canvas-workspace,
.app-shell[data-active-file="variables"] .canvas-workspace,
.app-shell[data-active-file="events"] .canvas-workspace {
  grid-template-rows: auto minmax(0, auto) 36px;
  align-content: start;
}

.canvas-workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 46px;
  padding: 7px 8px;
  overflow: auto hidden;
  border-bottom: 1px solid var(--background-modifier-border);
  background: var(--workspace-bar-bg);
}

.toolbar-group {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.toolbar-group {
  justify-content: flex-start;
}

.new-project-button {
  font-weight: 650;
}

.save-project-button {
  border-color: var(--interactive-accent);
  background: var(--interactive-accent);
  color: var(--text-on-accent);
  font-weight: 700;
}

.save-project-button:hover {
  border-color: var(--interactive-accent-hover);
  background: var(--interactive-accent-hover);
  color: var(--text-on-accent);
}

.preview-tab {
  cursor: pointer;
}

.preview-tab:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.spacer {
  flex: 1;
  min-width: 6px;
}

.toolbar-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border-color: var(--background-modifier-border);
  background: var(--background-secondary-alt);
  color: var(--text-muted);
}

.compact-button {
  padding: 0 8px;
}

.auto-layout-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--background-modifier-border);
}

.auto-layout-controls[hidden] {
  display: none;
}

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--background-modifier-border);
  border-radius: 50%;
  background: var(--background-secondary-alt);
  color: var(--text-muted);
  font-weight: 800;
  cursor: pointer;
  transition: 140ms ease;
}

.help-button:hover {
  border-color: var(--interactive-accent);
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.toolbar-button.primary,
.small-button.primary,
.play-action.primary {
  border-color: var(--interactive-accent);
  background: var(--interactive-accent);
  color: var(--text-on-accent);
}

.zoom-readout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 50px;
  height: 30px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  color: var(--text-muted);
  background: var(--background-control);
}

.canvas-workspace-view {
  display: none;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.canvas-workspace-view.active {
  display: block;
}

.canvas-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.canvas-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.canvas-history {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 12;
  display: inline-flex;
  gap: 6px;
  pointer-events: auto;
}

.canvas-history-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--background-modifier-border-hover);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--background-secondary) 88%, transparent);
  color: var(--text-normal);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
}

.canvas-history-button:hover:not(:disabled) {
  border-color: var(--interactive-accent);
  background: var(--background-modifier-hover);
}

.canvas-history-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.document-panel {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: var(--background-primary);
}

.document-panel.active {
  display: grid;
}

.document-shell {
  display: grid;
  align-content: start;
  gap: 16px;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.document-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--background-modifier-border);
}

.document-header > div {
  min-width: 0;
}

.document-header h2 {
  margin: 2px 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.document-actions {
  display: flex;
  flex: 1 1 320px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.document-meta {
  color: var(--text-muted);
  font-size: 12px;
}

.canvas-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background-color: var(--background-canvas);
  background-image:
    linear-gradient(var(--canvas-grid-small) 1px, transparent 1px),
    linear-gradient(90deg, var(--canvas-grid-small) 1px, transparent 1px),
    linear-gradient(var(--canvas-grid-large) 1px, transparent 1px),
    linear-gradient(90deg, var(--canvas-grid-large) 1px, transparent 1px);
  background-position: 0 0;
  background-size: 16px 16px, 16px 16px, 80px 80px, 80px 80px;
  outline: none;
}

.canvas-content {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 2600px;
}

.link-layer,
.node-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 2600px;
  transform-origin: 0 0;
}

.link-layer {
  overflow: visible;
  pointer-events: auto;
}

.node-layer {
  pointer-events: none;
}

.link-hitpath,
.link-path {
  fill: none;
  pointer-events: stroke;
}

.link-hitpath {
  stroke: transparent;
  stroke-width: 18;
  stroke-linecap: round;
}

.link-path {
  stroke: var(--link-color);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.link-path.selected {
  stroke: var(--interactive-accent-hover);
  stroke-width: 3;
}

.link-path.pending {
  stroke: var(--interactive-accent-hover);
  stroke-dasharray: 9 7;
}

.node {
  position: absolute;
  width: 230px;
  min-width: 140px;
  min-height: 96px;
  border: 1px solid var(--node-border);
  border-radius: var(--radius-m);
  background: var(--node-surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  user-select: none;
}

.node.frame {
  width: 420px;
  min-width: 260px;
  min-height: 160px;
}

.node.visual-frame {
  background: var(--visual-frame-surface);
  border-color: var(--visual-frame-border);
}

.node.event-frame {
  background: var(--event-frame-surface);
  border-color: var(--event-frame-border);
}

.node.frame .node-header {
  background: var(--frame-header-bg);
}

.node.visual-frame .node-header {
  border-bottom-color: var(--visual-frame-border);
}

.node.event-frame .node-header {
  border-bottom-color: var(--event-frame-border);
}

.node.selected {
  border-color: var(--focus-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--focus-accent) 55%, transparent), var(--shadow-soft);
}

.node.multi-selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-blue) 60%, transparent), var(--shadow-soft);
}

.marquee-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 2600px;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 90;
}

.marquee-rect {
  position: absolute;
  pointer-events: none;
  border: 1px solid var(--accent-blue);
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent-blue) 14%, transparent);
}

.node.character-focus-muted {
  opacity: 0.28;
}

.node.character-focus-match {
  border-color: var(--focus-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus-accent) 48%, transparent), var(--shadow-soft);
}

.node-header {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--node-header-border);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  background: var(--node-header-bg);
  cursor: grab;
}

.node:active .node-header {
  cursor: grabbing;
}

.node-icon {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--node-color);
  color: #101010;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  word-break: keep-all;
  cursor: pointer;
}

.node-icon[data-icon-size="double"] {
  font-size: 10px;
}

.node-icon[data-icon-size="wide"] {
  font-size: 8px;
}

.node-icon:hover,
.node-icon:focus-visible {
  outline: 1px solid var(--focus-accent);
  outline-offset: 2px;
}

.node:active .node-icon {
  cursor: pointer;
}

.node-type {
  color: var(--text-muted);
  font-size: 12px;
}

.node-id {
  color: var(--text-faint);
  font-size: 12px;
}

.node-body {
  padding: 12px 14px 14px;
  overflow: hidden;
}

.node-title {
  margin-bottom: 8px;
  color: var(--text-normal);
  font-weight: 700;
  line-height: 1.25;
}

.node-text {
  color: var(--text-normal);
  line-height: 1.45;
  white-space: pre-wrap;
}

.node-meta {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.node-cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: -2px 0 8px;
  min-width: 0;
}

.node-cast-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--node-color) 40%, var(--background-modifier-border));
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--node-color) 14%, var(--background-secondary-alt));
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-cast-chip.more {
  color: var(--text-faint);
}

.node-resize-handle {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
}

.node-resize-handle.right {
  top: 22px;
  right: -5px;
  bottom: 18px;
  width: 10px;
  cursor: ew-resize;
}

.node-resize-handle.bottom {
  right: 18px;
  bottom: -5px;
  left: 18px;
  height: 10px;
  cursor: ns-resize;
}

.node-resize-handle.corner {
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-s) 0 var(--radius-m) 0;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(220, 221, 222, 0.55) 50% 58%, transparent 58%),
    linear-gradient(135deg, transparent 0 66%, rgba(220, 221, 222, 0.4) 66% 73%, transparent 73%);
  cursor: nwse-resize;
}

.node.selected .node-resize-handle.corner,
.node:hover .node-resize-handle.corner {
  background-color: rgba(127, 109, 242, 0.18);
}

.port {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translateY(-50%);
  cursor: crosshair;
}

.port::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 1px solid #d6d6d6;
  border-radius: 50%;
  background: var(--background-primary);
  transform: translate(-50%, -50%);
}

.port:hover::before,
.port.active::before {
  border-color: var(--interactive-accent-hover);
  background: var(--interactive-accent-hover);
}

.port.input {
  left: -15px;
}

.port.output {
  right: -15px;
}

.selection-hint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: 420px;
  padding: 8px 10px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--overlay-bg);
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.selection-hint.show {
  opacity: 1;
}

.minimap {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  width: 180px;
  height: 118px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--minimap-bg);
  overflow: hidden;
  cursor: crosshair;
  transition: border-color 140ms ease;
}

.minimap:hover {
  border-color: var(--focus-accent);
}

.minimap-node {
  position: absolute;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: var(--node-color);
  opacity: 0.85;
}

.node-context-menu {
  position: absolute;
  z-index: 100;
  display: grid;
  min-width: 168px;
  padding: 5px;
  border: 1px solid var(--background-modifier-border-hover);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
  box-shadow: var(--shadow-soft);
}

.node-context-menu[hidden] {
  display: none !important;
}

.node-context-menu .context-menu-label {
  padding: 4px 10px 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--background-modifier-border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.node-context-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text-normal);
  text-align: left;
  cursor: pointer;
}

.node-context-menu button:hover {
  background: var(--background-modifier-hover);
}

.node-context-menu button:last-child {
  border-bottom: 0;
}

.node-context-menu .context-menu-danger {
  margin-top: 4px;
  border-top: 1px solid var(--background-modifier-border);
  color: var(--accent-red);
}

.node-context-menu .context-menu-danger:hover {
  background: color-mix(in srgb, var(--accent-red) 18%, transparent);
}

.mention-popover {
  position: fixed;
  z-index: 200;
  display: grid;
  min-width: 180px;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--background-modifier-border-hover);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
  box-shadow: var(--shadow-soft);
}

.mention-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text-normal);
  text-align: left;
  cursor: pointer;
}

.mention-option strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.mention-option small {
  color: var(--text-muted);
  font-size: 11px;
}

.mention-option:hover,
.mention-option.active {
  background: var(--background-modifier-hover);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  border-top: 1px solid var(--background-modifier-border);
  background: var(--workspace-bar-bg);
  color: var(--text-muted);
  text-align: left;
}

#statusText {
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
  text-align: left;
}

.canvas-search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  flex: 0 1 420px;
  max-width: 520px;
  min-width: 260px;
  gap: 8px;
  text-align: left;
}

.canvas-search-box input {
  background: var(--background-secondary-alt);
  border-color: var(--background-modifier-border-hover);
  color: var(--text-normal);
  -webkit-text-fill-color: var(--text-normal);
}

.canvas-search-box input:focus {
  background: var(--background-secondary-alt);
  color: var(--text-normal);
  -webkit-text-fill-color: var(--text-normal);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-control);
  color: var(--text-normal);
  caret-color: var(--text-normal);
  -webkit-text-fill-color: var(--text-normal);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
  -webkit-text-fill-color: var(--text-faint);
  opacity: 1;
}

input::selection,
textarea::selection {
  background: color-mix(in srgb, var(--interactive-accent) 56%, transparent);
  color: var(--text-on-accent);
  -webkit-text-fill-color: var(--text-on-accent);
}

input,
select {
  min-height: 30px;
  padding: 4px 8px;
}

textarea {
  min-height: 128px;
  padding: 8px;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--focus-accent);
  outline: none;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--background-modifier-border);
}

.inspector-tab {
  height: 30px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-tab.active {
  background: var(--background-modifier-active);
  color: var(--text-normal);
}

.inspector-tab:disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.55;
}

.inspector-panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px 40px;
}

.inspector-panel.active {
  display: block;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row .small-button {
  min-width: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
}

.stat-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 750;
}

.story-list {
  display: grid;
  gap: 6px;
}

.story-root-list,
.story-nested-list {
  min-height: 34px;
}

.story-nested-list {
  margin: 6px 0 4px 12px;
  padding-left: 10px;
  border-left: 1px solid var(--background-modifier-border);
}

.story-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.story-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.story-entry,
.story-frame {
  min-width: 0;
}

.story-frame summary {
  list-style: none;
}

.story-frame summary::-webkit-details-marker {
  display: none;
}

.story-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
  color: var(--text-normal);
  text-align: left;
  line-height: 1.25;
}

.story-frame-item {
  border-color: color-mix(in srgb, var(--node-color) 46%, var(--background-modifier-border));
  background: color-mix(in srgb, var(--node-color) 12%, var(--background-secondary-alt));
}

.story-event-frame-item {
  border-color: rgba(180, 140, 255, 0.72);
  background: rgba(180, 140, 255, 0.14);
  box-shadow: inset 3px 0 0 rgba(180, 140, 255, 0.68);
}

.story-item.selected {
  border-color: var(--focus-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--focus-accent) 46%, transparent);
}

.story-item.character-focus-muted {
  opacity: 0.42;
}

.story-item.character-focus-match {
  border-color: var(--focus-accent);
  box-shadow: inset 3px 0 0 var(--focus-accent);
}

.story-item.dragging {
  opacity: 0.52;
}

.story-item.story-drop-before {
  border-top-color: var(--interactive-accent);
  box-shadow: inset 0 2px 0 var(--interactive-accent);
}

.story-item.story-drop-after {
  border-bottom-color: var(--interactive-accent);
  box-shadow: inset 0 -2px 0 var(--interactive-accent);
}

.story-item.story-drop-inside,
.story-list.story-drop-inside {
  outline: 1px dashed var(--interactive-accent);
  outline-offset: 2px;
}

.story-drag-handle {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}

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

.story-item-title {
  display: block;
  width: 100%;
  font-weight: 700;
  font-size: 14px;
}

.story-item-meta {
  display: block;
  width: 100%;
  color: var(--text-muted);
  font-size: 12px;
}

.story-focus-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-secondary);
  color: var(--text-muted);
  cursor: pointer;
}

.story-focus-button:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.story-empty-drop {
  min-height: 32px;
  padding: 8px 10px;
  border: 1px dashed var(--background-modifier-border);
  border-radius: var(--radius-s);
  color: var(--text-faint);
  font-size: 12px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  align-items: start;
}

.character-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary);
}

.character-search-box {
  display: inline-flex;
  align-items: center;
  flex: 0 1 220px;
  min-width: 160px;
}

.character-search-box input {
  width: 100%;
}

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

.character-card.focused {
  border-color: color-mix(in srgb, var(--focus-accent) 68%, var(--background-modifier-border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--focus-accent) 42%, transparent);
}

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

.character-card-actions {
  display: flex;
  gap: 6px;
  align-items: end;
}

.character-card textarea {
  min-height: 104px;
}

.danger-button {
  color: var(--text-muted);
}

.danger-button:hover {
  border-color: rgba(224, 108, 117, 0.5);
  color: var(--accent-red);
}

.small-button.danger-button {
  border-color: rgba(224, 108, 117, 0.28);
}

.small-button.danger-button:hover {
  background: rgba(224, 108, 117, 0.1);
}

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

.character-backlink-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.character-backlink-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.character-backlink-group h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.linked-node {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 8px 10px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-secondary-alt);
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}

.linked-node:hover {
  border-color: var(--background-modifier-border-hover);
  color: var(--text-normal);
}

.linked-node.empty {
  cursor: default;
}

.character-backlink-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: flex-start;
  min-width: 0;
}

.character-backlink-main strong,
.character-backlink-main small,
.character-backlink-snippet {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-backlink-main strong {
  min-width: 0;
  color: var(--text-normal);
  white-space: nowrap;
  line-height: 1.3;
}

.character-backlink-main small {
  flex: 0 0 auto;
  max-width: 42%;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.character-backlink-snippet {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.variable-table {
  display: grid;
  gap: 6px;
}

.playbook-section {
  display: grid;
  gap: 8px;
}

.playbook-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.playbook-section-header h3 {
  margin: 0;
  color: var(--text-normal);
  font-size: 14px;
  font-weight: 700;
}

.playbook-section-header span {
  color: var(--text-muted);
  font-size: 12px;
}

.variable-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(110px, 140px) minmax(180px, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary);
}

.variable-heading {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.playbook-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.playbook-rule-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary);
}

.playbook-rule-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.playbook-rule-card h4 {
  margin: 2px 0 0;
  color: var(--text-normal);
  font-size: 16px;
  line-height: 1.2;
}

.playbook-rule-kind {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.playbook-rule-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.playbook-rule-card dl div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.playbook-rule-card dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.playbook-rule-card dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-normal);
  font-family: monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.json-field textarea {
  min-height: 520px;
  overflow-y: hidden;
  font-family: monospace;
  font-size: 13px;
}

.cast-editor {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
}

.cast-editor-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.cast-editor-header h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.cast-editor-header span,
.cast-auto-row > span,
.cast-empty {
  color: var(--text-faint);
  font-size: 12px;
}

.cast-row-list {
  display: grid;
  gap: 6px;
}

.cast-row,
.cast-add-row {
  display: grid;
  gap: 6px;
  align-items: stretch;
}

.cast-row {
  grid-template-columns: minmax(0, 1fr) minmax(96px, 0.65fr) 34px;
}

.cast-add-row {
  grid-template-columns: minmax(0, 1fr) minmax(96px, 0.65fr) auto;
}

.cast-row select,
.cast-add-row select {
  min-width: 0;
}

.cast-auto-row {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--background-modifier-border);
}

.cast-auto-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.event-fields {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--subtle-button-bg);
}

.event-fields h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.custom-fields {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
}

.custom-fields h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.event-sheet-shell {
  grid-template-rows: auto minmax(0, 1fr);
  max-width: none;
}

.event-sheet-shell .document-actions .small-button {
  flex: 0 1 auto;
}

.event-search-box {
  display: inline-flex;
  align-items: center;
  flex: 0 1 220px;
  min-width: 160px;
}

.event-search-box input {
  width: 100%;
}

.event-sheet-groups {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.event-sheet-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.event-sheet-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
}

.event-sheet-group-header h3 {
  margin: 0;
  color: var(--text-normal);
  font-size: 14px;
  font-weight: 700;
}

.event-sheet-group-header span {
  font-size: 12px;
}

.event-sheet-scroll {
  overflow: auto;
  max-width: 100%;
  min-height: 0;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary);
}

.event-sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.event-row-handle-col {
  width: 28px;
}

.event-row-handle-cell {
  padding: 0;
  text-align: center;
  vertical-align: middle;
  user-select: none;
}

.event-row-drag-handle {
  display: inline-block;
  padding: 4px 6px;
  color: var(--text-faint);
  cursor: grab;
  line-height: 1;
}

.event-row-drag-handle:active {
  cursor: grabbing;
}

.event-sheet-table tbody tr.event-row-drop-before > td:first-child,
.event-sheet-table tbody tr.event-row-drop-before > th {
  box-shadow: inset 0 2px 0 var(--interactive-accent);
}

.event-sheet-table tbody tr.event-row-drop-after > td:first-child,
.event-sheet-table tbody tr.event-row-drop-after > th {
  box-shadow: inset 0 -2px 0 var(--interactive-accent);
}

.event-sheet-table th,
.event-sheet-table td {
  max-width: 420px;
  border-bottom: 1px solid var(--background-modifier-border);
  border-right: 1px solid var(--background-modifier-border);
  padding: 6px;
  vertical-align: top;
  overflow: hidden;
}

.event-sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--background-secondary-alt);
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
  white-space: normal;
  overflow-wrap: normal;
}

.event-column-header {
  display: grid;
  align-content: start;
  gap: 6px;
}

.event-column-name {
  display: block;
  min-width: 0;
  color: var(--text-muted);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: normal;
  word-break: normal;
}

.event-column-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.event-column-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-primary);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 650;
  line-height: 1;
  opacity: 0.78;
}

.event-sheet-table thead th:hover .event-column-button {
  opacity: 1;
}

.event-column-button:hover {
  border-color: var(--interactive-accent);
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.event-column-button:focus-visible {
  opacity: 1;
  border-color: var(--focus-accent);
}

.event-column-button.danger:hover {
  border-color: rgba(224, 108, 117, 0.45);
  background: rgba(224, 108, 117, 0.1);
  color: var(--accent-red);
}

.event-node-col {
  width: 230px;
}

.event-hidden-col {
  width: 190px;
}

.event-sheet-table thead th:last-child,
.event-sheet-table tbody td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  border-left: 1px solid var(--background-modifier-border);
}

.event-sheet-table thead th:last-child {
  z-index: 3;
}

.event-hidden-cell {
  min-width: 180px;
  background: color-mix(in srgb, var(--background-secondary-alt) 42%, transparent);
}

.event-hidden-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-hidden-restore-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-primary);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.event-hidden-restore-button:hover {
  border-color: var(--interactive-accent);
  color: var(--text-normal);
}

.event-hidden-empty {
  color: var(--text-faint);
  font-size: 12px;
}

.event-node-link {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--subtle-button-border);
  border-radius: var(--radius-s);
  background: var(--subtle-button-bg);
  color: var(--text-normal);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}

.event-node-link span,
.event-node-link small {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: center;
  line-height: 1.25;
}

.event-node-link small {
  color: var(--text-faint);
  font-size: 11px;
}

.event-sheet-table input,
.event-sheet-table textarea {
  min-width: 100%;
  max-width: 100%;
  border-color: transparent;
  background: var(--background-control);
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-sheet-table textarea {
  min-height: 72px;
  resize: vertical;
}

.event-elements-cell {
  min-height: 72px;
  max-width: 100%;
  padding: 8px;
  border-radius: var(--radius-s);
  background: var(--subtle-button-bg);
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.event-elements-cell.empty {
  color: var(--text-faint);
}

.event-elements-collapsible {
  display: block;
}

.event-elements-collapsible summary {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin: -2px -2px 8px;
  padding: 4px 6px;
  border-radius: var(--radius-s);
  color: var(--text-normal);
  cursor: pointer;
  list-style-position: inside;
}

.event-elements-collapsible summary:hover {
  background: var(--background-modifier-hover);
}

.event-elements-full {
  display: none;
}

.event-elements-collapsible[open] .event-elements-preview {
  display: none;
}

.event-elements-collapsible[open] .event-elements-full {
  display: block;
}

.event-sheet-empty {
  min-height: 120px;
  color: var(--text-muted);
  text-align: center;
}

.play-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--background-modifier-border-hover);
  border-radius: var(--radius-m);
  padding: 0;
  background: var(--background-secondary);
  color: var(--text-normal);
  box-shadow: var(--shadow-soft);
}

.play-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.confirm-dialog,
.icon-dialog,
.type-dialog,
.notice-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  padding: 0;
  background: var(--background-secondary);
  color: var(--text-normal);
  box-shadow: var(--shadow-soft);
}

.playbook-help-dialog {
  width: min(680px, calc(100vw - 32px));
}

.playbook-rule-dialog {
  width: min(620px, calc(100vw - 32px));
}

.confirm-dialog::backdrop,
.icon-dialog::backdrop,
.type-dialog::backdrop,
.notice-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.confirm-shell,
.icon-shell,
.type-shell {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.confirm-shell h2,
.icon-shell h2,
.type-shell h2 {
  margin: 4px 0 0;
  font-size: 16px;
  line-height: 1.45;
}

.confirm-body {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.icon-shell input {
  height: 38px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}

.type-dialog-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.type-shell textarea {
  min-height: 96px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--text-muted);
  font-size: 13px;
}

.checkbox-field input {
  width: auto;
  min-height: 0;
}

.notice-shell {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.notice-shell p {
  margin: 0;
  color: var(--text-normal);
  font-size: 15px;
  line-height: 1.45;
}

.playbook-help-shell {
  gap: 16px;
}

.playbook-rule-shell {
  gap: 14px;
}

.playbook-help-shell h2 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.35;
}

.playbook-rule-shell h2 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.35;
}

.playbook-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.playbook-help-grid section {
  min-width: 0;
}

.playbook-help-grid h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-normal);
}

.playbook-help-grid ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.playbook-help-grid code,
.playbook-example {
  font-family: monospace;
}

.playbook-example {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-s);
  background: var(--background-primary);
  color: var(--text-normal);
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

.playbook-rule-options {
  display: grid;
  gap: 8px;
}

.playbook-rule-options button {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--radius-m);
  background: var(--background-secondary-alt);
  color: var(--text-normal);
  text-align: left;
  appearance: none;
}

.playbook-rule-options button:hover {
  border-color: var(--focus-accent);
  background: var(--background-modifier-hover);
}

.playbook-rule-options strong {
  font-size: 14px;
  line-height: 1.2;
}

.playbook-rule-options span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.25;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.confirm-muted {
  border-color: var(--background-modifier-border);
  background: var(--background-secondary-alt);
  color: var(--text-muted);
}

.confirm-cancel {
  border-color: var(--interactive-accent);
  background: var(--interactive-accent);
  color: var(--text-on-accent);
}

.play-shell {
  margin: 0;
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--background-modifier-border);
}

.play-body {
  min-height: 260px;
  padding: 24px;
  background: var(--background-primary);
  font-family: var(--font-text);
  font-size: 18px;
  line-height: 1.6;
}

.play-body h3 {
  margin: 0 0 12px;
  font-family: var(--font-interface);
  font-size: 20px;
}

.play-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-family: var(--font-interface);
  font-size: 12px;
}

.play-body p {
  margin: 0;
  white-space: pre-wrap;
}

.play-fields {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  font-family: var(--font-interface);
  font-size: 13px;
}

.play-fields div {
  display: grid;
  grid-template-columns: minmax(90px, 160px) minmax(0, 1fr);
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--background-modifier-border);
}

.play-fields dt {
  color: var(--text-muted);
  font-weight: 650;
}

.play-fields dd {
  margin: 0;
  color: var(--text-normal);
  white-space: pre-wrap;
}

.play-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--background-modifier-border);
}

.play-action {
  min-height: 34px;
  padding: 0 12px;
  border-color: var(--background-modifier-border);
  background: var(--background-secondary-alt);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--background-modifier-border);
  border-radius: var(--radius-m);
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 1320px) {
  .app-shell {
    --sidebar-left-width: 240px;
    --sidebar-right-width: 320px;
    --workspace-min-width: 360px;
  }
}

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

  .app-shell {
    --workspace-min-width: 360px;
    width: max(1000px, calc(var(--sidebar-left-track) + var(--sidebar-left-resizer-width) + var(--workspace-min-width) + var(--sidebar-right-resizer-width) + var(--sidebar-right-track)));
    min-width: max(1000px, calc(var(--sidebar-left-track) + var(--sidebar-left-resizer-width) + var(--workspace-min-width) + var(--sidebar-right-resizer-width) + var(--sidebar-right-track)));
    height: 100vh;
    min-height: 100vh;
  }

  .canvas-workspace {
    min-height: 100vh;
    grid-template-rows: auto minmax(560px, calc(100vh - 150px)) auto;
  }

  .canvas-workspace-tabs {
    flex-wrap: wrap;
    height: auto;
  }

  .canvas-panel {
    min-height: 560px;
  }

  .document-panel {
    min-height: 560px;
  }

  .document-header,
  .variable-row {
    grid-template-columns: 1fr;
  }

  .document-header {
    display: grid;
  }

  .playbook-help-grid {
    grid-template-columns: 1fr;
  }

  .status-bar {
    flex-wrap: wrap;
    min-height: 96px;
  }

  .app-shell[data-active-file="characters"] .canvas-workspace,
  .app-shell[data-active-file="variables"] .canvas-workspace,
  .app-shell[data-active-file="events"] .canvas-workspace {
    min-height: 0;
    grid-template-rows: auto auto auto;
  }

  .app-shell[data-active-file="characters"] .document-panel,
  .app-shell[data-active-file="variables"] .document-panel,
  .app-shell[data-active-file="events"] .document-panel {
    min-height: 0;
  }

  .app-shell[data-active-file="characters"] .status-bar,
  .app-shell[data-active-file="variables"] .status-bar,
  .app-shell[data-active-file="events"] .status-bar {
    min-height: 0;
  }
}

[hidden] {
  display: none;
}
