/* Top-right control cluster: history dropdown, new / recenter / theme */
#toolbar {
  position: fixed;
  z-index: 10;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 8px 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background-image: linear-gradient(var(--node-bg), var(--node-bg)), var(--border-grad);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 4px 18px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  backdrop-filter: blur(6px);
  transition: background-image 0.3s ease, box-shadow 0.3s ease;
}

/* On desktop #toolbar-content generates no box of its own, so its children
   lay out directly as flex items of #toolbar - the mobile collapsed/dropdown
   behavior lives entirely in responsive.css. */
#toolbar-content {
  display: contents;
}
#menu-toggle {
  display: none;
}
.btn-label {
  display: none; /* only shown in the mobile stacked menu */
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--node-border);
  margin: 0 2px;
  flex: none;
}

/* History dropdown */
#history-group {
  position: relative;
  display: flex;
  align-items: center;
}
#history-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 150px;
  height: 30px;
  padding: 0 10px 0 4px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 13px;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s ease;
}
#history-toggle:hover {
  background: rgba(128,128,128,0.10);
}
#history-toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#history-toggle svg {
  flex: none;
  color: var(--muted);
  transition: transform 0.2s ease;
}
#history-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

#history-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 6px;
  width: 280px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid transparent;
  border-radius: 16px;
  background-image: linear-gradient(var(--node-bg), var(--node-bg)), var(--border-grad);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.06);
  backdrop-filter: blur(8px);
}
.history-empty {
  padding: 14px 12px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.history-item + .history-item {
  margin-top: 1px;
}
.history-item:hover {
  background: rgba(var(--gold-glow-rgb),0.12);
}
.history-item.current {
  background-image: linear-gradient(rgba(var(--gold-glow-rgb),0.14), rgba(var(--gold-glow-rgb),0.14)),
                     linear-gradient(135deg, var(--gold-1), var(--gold-2), var(--gold-3));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1px solid transparent;
}
.history-item-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.history-item-title {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-date {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}
.history-item-del {
  flex: none;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.history-item-del:hover {
  opacity: 1;
  color: #c0392b;
  background: rgba(192,57,43,0.12);
}

/* Action buttons */
#new-btn {
  height: 30px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background-image: linear-gradient(var(--node-bg), var(--node-bg)),
                     linear-gradient(135deg, var(--gold-1), var(--gold-2), var(--gold-3));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--text);
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#new-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 10px 1px rgba(var(--gold-glow-rgb),0.25);
}

#theme-toggle, #recenter-btn {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
#theme-toggle:hover, #recenter-btn:hover {
  color: var(--text);
  background: rgba(128,128,128,0.10);
  transform: scale(1.08);
}

/* Zoom controls */
#zoom-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
#zoom-group button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
#zoom-out-btn, #zoom-in-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#zoom-out-btn:hover, #zoom-in-btn:hover {
  color: var(--text);
  background: rgba(128,128,128,0.10);
}
#zoom-label {
  min-width: 40px;
  height: 26px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 11px;
  font-family: inherit;
}
#zoom-label:hover {
  color: var(--text);
  background: rgba(128,128,128,0.10);
}
