:root {
  --bg-page: #010409;
  --bg-card: #0d1117;
  --bg-header: #161b22;
  --border: #30363d;
  --text-main: #e6edf3;
  --text-muted: #7d8590;
  --link: #58a6ff;
  --hover-bg: rgba(56, 139, 253, 0.12);
  --accent: #2ea043;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

.widget-card {
  width: 100%;
  max-width: 920px;
  height: 100%;
  max-height: 460px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.widget-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.repo-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.repo-badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.repo-badge a {
  color: var(--text-main);
  text-decoration: none;
}

.repo-badge a:hover {
  color: var(--link);
  text-decoration: underline;
}

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

.controls button {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.controls button:hover:not(:disabled) {
  background: #21262d;
  border-color: #8b949e;
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.controls .text-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
}

#zoom-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
  font-family: monospace;
}

.builder-panel {
  background: #161b22;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.builder-panel.hidden {
  display: none;
}

.builder-row, .snippet-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-panel input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  flex: 1;
}

.builder-panel .branch-input {
  max-width: 110px;
}

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

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

.viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
  background-image: radial-gradient(#21262d 1px, transparent 1px);
  background-size: 20px 20px;
}

.viewport:active {
  cursor: grabbing;
}

.canvas {
  padding: 24px;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  display: inline-block;
}

.canvas.dragging {
  transition: none;
}

.tree-container {
  font-family: "JetBrains Mono", "Fira Code", "Hack Nerd Font", monospace;
  font-size: 14px;
  line-height: 1.7;
}

.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 2px 10px;
  border-radius: 6px;
  transition: background 0.18s ease, transform 0.18s ease;
}

.tree-row:hover {
  background: var(--hover-bg);
  transform: translateX(4px);
}

.tree-left {
  display: flex;
  align-items: center;
  white-space: pre;
}

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

.icon {
  margin-right: 6px;
  transition: transform 0.18s ease;
}

.tree-row:hover .icon {
  transform: scale(1.15);
}

.node-link {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

.node-link.folder {
  color: #79c0ff;
  font-weight: 700;
}

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

.node-desc {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.tree-row:hover .node-desc {
  color: var(--text-main);
}

.widget-footer {
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}