body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  background: #0f1115;
  color: #ddd;
}
#toolbar {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  background: #0b0d12;
  border-bottom: 1px solid #222;
  transition:
    transform 0.25s ease,
    opacity 0.2s ease,
    height 0.25s ease;
  will-change: transform, opacity, height;
}
#toolbar input,
#toolbar select,
#toolbar button {
  background: #111;
  color: #ddd;
  border: 1px solid #333;
  padding: 4px 8px;
}
#srcPanel {
  z-index: 1000;
}
#toolbar.collapsed {
  transform: translateY(-100%);
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}
#srcPanel.collapsed {
  transform: translateY(-100%);
  opacity: 0;
  height: 0;
  padding: 0 8px;
  overflow: hidden;
}

/* Node highlight styling */
svg .node rect,
svg .node polygon,
svg .node path {
  transition:
    fill 120ms ease,
    filter 120ms ease;
}

svg .node:hover rect,
svg .node:hover polygon,
svg .node:hover path {
  fill: rgba(0, 170, 255, 0.25); /* fon */
  filter: drop-shadow(0 0 11px rgba(0, 170, 255, 0.6)); /* glow */
}

/* Keyboard-selected node styling */
svg g.node.selected-node rect,
svg g.node.selected-node polygon,
svg g.node.selected-node path {
  fill: rgba(0, 170, 255, 0.28);
  filter: drop-shadow(0 0 14px rgba(0, 170, 255, 0.9));
  transition:
    fill 120ms ease,
    filter 120ms ease;
}

p,
div,
div > *:not(textarea):not(input) {
  user-select: none;
}

#toggleToolbar {
  cursor: pointer;
  background: #1f2020;
  color: #ccc;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 4px 8px;
}

#preview svg {
  width: 100%;
  height: auto;
  padding: 12px;
  position: relative;
  overflow: visible;
  display: block; /* removes inline centering */
  margin: 0; /* removes auto-indents */
  transform-origin: 0 0; /* transformation anchor */
}
#preview svg g {
  transform-origin: 0 0;
}
#main {
  display: grid;
  grid-template-columns: 0.5fr 1fr;
  height: 100%;
  overflow: hidden;
}
textarea {
  width: 100%;
  height: 100%;
  background: #0b0d12;
  color: #e6e6e6;
  border: none;
  padding: 12px;
  font-family: monospace;
  font-size: 14px;
}

.toolbar-sep {
  width: 1px;
  background: #333;
  margin: 0 4px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.modal.hidden {
  display: none;
}
.modal-content {
  background: #16181d;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 20px;
  min-width: 360px;
  max-width: 90vw;
  color: #ddd;
}
.modal-content h3 {
  margin: 0 0 12px;
}
.modal-content input {
  width: 100%;
  box-sizing: border-box;
  background: #111;
  color: #ddd;
  border: 1px solid #333;
  padding: 6px 10px;
  font-family: monospace;
  margin: 8px 0;
}
.modal-content label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-top: 8px;
}
.modal-content code {
  background: #222;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
.modal-actions button {
  background: #111;
  color: #ddd;
  border: 1px solid #333;
  padding: 5px 14px;
  cursor: pointer;
}
.modal-actions button:hover {
  background: #222;
}

/* File browser */
.modal-wide {
  min-width: 520px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.breadcrumb {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.breadcrumb span {
  cursor: pointer;
  color: #5bf;
}
.breadcrumb span:hover {
  text-decoration: underline;
}
.file-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  border: 1px solid #222;
  border-radius: 4px;
  margin: 6px 0;
}
.file-list .file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #1a1a1a;
}
.file-list .file-item:hover {
  background: #1e2028;
}
.file-list .file-item:last-child {
  border-bottom: none;
}
.file-list .file-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}
.file-list .file-name {
  flex: 1;
  font-size: 14px;
}
.file-list .loading-msg,
.file-list .error-msg {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: #888;
}
.file-list .error-msg {
  color: #f66;
}

/* Save area in file browser */
.gh-save-area {
  margin-top: 8px;
  flex-shrink: 0;
}
.gh-save-area.hidden {
  display: none;
}
.gh-save-area label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-top: 6px;
}
.gh-save-area input {
  width: 100%;
  box-sizing: border-box;
  background: #111;
  color: #ddd;
  border: 1px solid #333;
  padding: 6px 10px;
  font-family: monospace;
  margin-top: 4px;
}
