/* ============ Skill Tree ============ */
.skilltree-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

/* ============ Export ============ */
.st-export-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 3px 8px 3px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.st-export-btn:hover {
  border-color: var(--accent);
}

.st-export-btn .material-symbols-outlined {
  font-size: 16px;
}

.st-export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  padding: 4px 0;
}

.st-export-menu.open {
  display: block;
}

.st-export-item {
  display: block;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.st-export-item:hover {
  background: var(--bg-hover);
}

.st-export-error {
  display: none;
  margin-left: auto;
  font-size: 11px;
  color: var(--danger);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.st-export-error.visible {
  display: block;
}

.st-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-dark);
  cursor: grab;
}

.st-viewport.st-panning {
  cursor: grabbing;
}

.st-board {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  transform-origin: 0 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  will-change: transform;
}

/* ============ SVG Lines ============ */
.st-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  pointer-events: none;
  z-index: 1;
}

/* ============ Center Info Panel ============ */
.st-center-panel {
  position: absolute;
  width: 180px;
  padding: 16px;
  border-radius: 12px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  z-index: 4;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.st-center-icon {
  font-size: 28px;
}

.st-center-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.st-center-bar-track {
  width: 140px;
  height: 6px;
  background: var(--bg-dark);
  border-radius: 3px;
  overflow: hidden;
}

.st-center-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.st-center-milestone {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.st-center-milestone-label {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ============ Category Label ============ */
.st-category-label {
  position: absolute;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.st-category-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============ Circular Card ============ */
.st-card {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border: 2px solid var(--cardBorders);
  cursor: pointer;
  z-index: 3;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.st-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.st-card.unlocked {
  opacity: 1;
}

.st-card.locked {
  opacity: 0.5;
}

.st-card.locked:hover {
  opacity: 0.8;
}

.st-card-icon {
  font-size: 24px;
}

.st-card-status {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 14px;
  background: var(--bg-dark);
  border-radius: 50%;
  padding: 1px;
  line-height: 1;
}

.st-card.locked .st-card-status {
  color: var(--text-muted);
}

/* ============ Popup ============ */
.st-popup {
  position: absolute;
  width: 280px;
  background: var(--bg-light);
  border: 1px solid var(--cardBorders);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 10;
  overflow: hidden;
}

.st-popup-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.st-popup-header .material-symbols-outlined {
  font-size: 20px;
}

.st-popup-name {
  flex: 1;
}

.st-popup-close {
  cursor: pointer;
  font-size: 18px !important;
  color: var(--text-muted);
  border-radius: 3px;
  padding: 2px;
}

.st-popup-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.st-popup-body {
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.st-popup-body p {
  margin: 0 0 10px;
}

.st-popup-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.st-popup-category {
  font-size: 11px;
  font-weight: 600;
}

.st-popup-prereqs {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0;
  margin-bottom: 8px;
  border-top: 1px solid var(--border);
}

.st-popup-claim {
  display: block;
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  text-align: center;
  transition: background 0.15s;
}

.st-popup-claim:hover {
  background: var(--accent-hover);
}

.st-popup-claim.disabled {
  background: var(--bg-mid);
  color: var(--text-muted);
  cursor: not-allowed;
}

.st-popup-claimed {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 8px;
  color: var(--success);
  font-weight: 600;
  font-size: 12px;
}

/* ============ Zoom Level ============ */
.st-zoom-level {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.6);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
}

/* ============ Edit toolbar ============ */
.st-edit-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 3px 8px 3px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.st-edit-btn .material-symbols-outlined {
  font-size: 16px;
}

.st-edit-btn:hover {
  border-color: var(--accent);
}

.st-edit-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-active);
}

.st-edit-tools {
  display: none;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.skilltree-toolbar.editing .st-edit-tools {
  display: flex;
}

.st-tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 3px 7px 3px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.st-tool-btn .material-symbols-outlined {
  font-size: 15px;
}

.st-tool-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text-primary);
}

.st-tool-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-active);
}

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

.st-tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

.st-spacing-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.st-spacing-input {
  width: 52px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 11px;
  font-family: inherit;
  outline: none;
}

.st-spacing-input:focus {
  border-color: var(--accent);
}

.st-toolbar-warn {
  display: none;
  font-size: 11px;
  color: var(--warning);
  white-space: nowrap;
  flex-shrink: 0;
}

.st-toolbar-warn.visible {
  display: block;
}

.st-toolbar-hint {
  flex: 1 1 40px;
  min-width: 0;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-toolbar-msg {
  display: none;
  font-size: 11px;
  color: var(--success);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30%;
  flex-shrink: 0;
}

.st-toolbar-msg.visible {
  display: block;
}

.st-toolbar-msg.error {
  color: var(--danger);
}

.st-export-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============ Edit mode: guides ============ */
.st-guides {
  pointer-events: none;
}

.st-guide-ring {
  fill: none;
  stroke: rgba(255,255,255,0.14);
  stroke-width: 1.5;
  stroke-dasharray: 7 9;
}

.st-guide-ring.hot {
  stroke: var(--accent);
  stroke-width: 2.5;
}

.st-guide-boundary {
  stroke: rgba(255,255,255,0.09);
  stroke-width: 1;
  stroke-dasharray: 4 9;
}

.st-guide-wedge {
  stroke: none;
  fill-opacity: 0;
}

.st-card.editable {
  cursor: grab;
}

.st-card.editable:hover {
  box-shadow: 0 0 0 3px rgba(74,144,217,0.35), 0 4px 14px rgba(0,0,0,0.4);
}

.st-card.dragging {
  cursor: grabbing;
  pointer-events: none;
  opacity: 0.85;
  z-index: 6;
  box-shadow: 0 10px 26px rgba(0,0,0,0.5);
}

.st-card.link-source {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(74,144,217,0.3);
}

.st-card.link-target {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(80,176,112,0.35);
}

.st-category-label.editable {
  pointer-events: auto;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}

.st-category-label.editable:hover {
  background: var(--bg-hover);
}

.st-category-icon {
  font-size: 14px;
}

.st-category-edit {
  font-size: 13px !important;
  color: var(--text-muted);
}

.st-link-preview {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.9;
}

.st-link-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  stroke-linecap: round;
}

.st-lines.link-tool .st-link-hit {
  pointer-events: stroke;
  cursor: pointer;
}

.st-connector {
  pointer-events: none;
}

.st-lines.link-tool .st-connector.hot {
  stroke: var(--danger) !important;
  stroke-width: 3 !important;
  stroke-dasharray: none !important;
  opacity: 1 !important;
}

.st-viewport.st-editing {
  cursor: default;
}

.st-viewport.st-linking {
  cursor: crosshair;
}

/* Sits under the pointer while a ring is hovered, so the glyph is nudged to
   the right of the cursor and the button stays the thing being clicked. */
.st-add-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  z-index: 8;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  user-select: none;
  animation: st-chip-pop 130ms ease-out;
}

/* The pop only ever scales up: shrinking the button would also shrink what the
   pointer can hit during the animation. */
@keyframes st-chip-pop {
  from { transform: scale(1.3); opacity: 0.45; }
  to { transform: scale(1); opacity: 1; }
}

.st-add-btn:hover {
  background: var(--accent-hover);
}

.st-add-btn[hidden] {
  display: none;
}

/* ============ Dialogs ============ */
.st-dialog {
  position: absolute;
  width: 300px;
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  background: var(--bg-light);
  border: 1px solid var(--cardBorders);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 12;
  overflow: hidden;
}

.st-dialog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.st-dialog-header .material-symbols-outlined {
  font-size: 18px;
}

.st-dialog-title {
  flex: 1;
}

.st-dialog-close {
  cursor: pointer;
  font-size: 18px !important;
  color: var(--text-muted);
  border-radius: 3px;
  padding: 2px;
}

.st-dialog-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.st-dialog-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
}

.st-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-field > label {
  font-size: 11px;
  color: var(--text-muted);
}

.st-field.invalid .st-input {
  border-color: var(--danger);
}

.st-input,
.st-select {
  width: 100%;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

.st-input:focus,
.st-select:focus {
  border-color: var(--accent);
}

textarea.st-input {
  resize: vertical;
  min-height: 38px;
}

.st-icon-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-icon-search {
  width: 100%;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 11px;
  font-family: inherit;
  outline: none;
}

.st-icon-search:focus {
  border-color: var(--accent);
}

.st-icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 116px;
  overflow-y: auto;
  padding: 3px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.st-icon-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  padding: 0;
}

.st-icon-cell:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* The random icon a new achievement starts with has to be findable at a
   glance, so the selection reads as a filled cell, not just a tinted glyph. */
.st-icon-cell.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(74, 144, 217, 0.2);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.st-icon-cell[hidden] {
  display: none;
}

.st-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.st-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.st-swatch:hover {
  border-color: var(--accent);
}

.st-swatch.selected {
  border-color: var(--text-primary);
}

.st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.st-chips-empty {
  font-size: 11px;
  color: var(--text-muted);
}

.st-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 7px;
  border-radius: 10px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
}

.st-chip-x {
  font-size: 13px !important;
  color: var(--text-muted);
  cursor: pointer;
}

.st-chip-x:hover {
  color: var(--danger);
}

.st-dialog-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.st-dialog-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-mid);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.st-dialog-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* Cancel and Save are pushed to the right, leaving room for Delete on the left. */
.st-dialog-row .st-dialog-cancel {
  margin-left: auto;
}

.st-btn {
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-mid);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.st-btn:hover {
  border-color: var(--accent);
}

.st-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.st-btn.danger {
  background: none;
  border-color: var(--danger);
  color: var(--danger);
}

.st-btn.danger.confirming {
  background: var(--danger);
  color: #fff;
}

