.toolbox-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(79, 70, 229, 0.45);
  transition: transform 0.2s, box-shadow 0.2s;
}

.toolbox-fab:hover {
  transform: scale(1.05) translateY(-2px);
}

.tools-launch {
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tools-launch .tool-btn {
  width: 100%;
}

.tool-btn--compact {
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  width: 100%;
  margin-top: 0.35rem;
}

/* Floating mini tools */
.float-tool {
  position: fixed;
  z-index: 52;
  left: 12px;
  top: 68px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.15);
  backdrop-filter: blur(8px);
  padding: 0.65rem 0.75rem 0.75rem;
  max-width: min(220px, calc(100vw - 1.5rem));
}

.float-tuner {
  max-width: min(260px, calc(100vw - 1.5rem));
}

.float-tool.is-dragging {
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.25);
  transition: none;
}

.float-tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 0.15rem 0;
  margin: -0.15rem 0 0.35rem;
  border-radius: 8px;
}

.float-tool-header:active {
  cursor: grabbing;
}

.float-tool-drag-hint {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.25rem;
}

.float-tool-close {
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 50%;
  background: var(--section-bg);
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.tuner-display--float {
  padding: 0.25rem 0;
  text-align: center;
}

.tuner-display--float .tuner-note {
  font-size: 2.25rem;
}

.tuner-meter--float {
  height: 8px;
  margin: 0.4rem 0;
}

.tuner-strings--float {
  grid-template-columns: repeat(6, 1fr);
  gap: 0.25rem;
  margin: 0.35rem 0;
}

.tuner-strings--float .tuner-string-btn {
  padding: 0.35rem 0.15rem;
  font-size: 0.7rem;
}

.float-tuner-sub {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.35rem;
  min-height: 1.2em;
}

.metro-bpm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.metro-bpm-display--float .metro-bpm-value {
  font-size: 2rem;
}

.metro-bpm-display--float .metro-bpm-label {
  font-size: 0.7rem;
}

.metro-bpm-step {
  border: 1px solid var(--border);
  background: var(--bg);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  color: var(--accent);
}

.metro-slider--float {
  width: 100%;
  margin: 0.5rem 0;
}

.metro-beat-visual--float {
  margin: 0.35rem 0;
  min-height: 1.5rem;
}

.tools-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  z-index: 110;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tools-backdrop.is-open {
  opacity: 1;
}

.tools-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  max-height: 88dvh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 48px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}

.tools-panel.is-open {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .tools-panel {
    left: auto;
    right: 1rem;
    bottom: 1rem;
    width: min(400px, calc(100% - 2rem));
    max-height: 80dvh;
    border-radius: 16px;
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    pointer-events: none;
  }

  .tools-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}

.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.15rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 100%);
  border-radius: 20px 20px 0 0;
}

.tools-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
}

.tools-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.tools-close {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: var(--section-bg);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.tools-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--section-bg);
}

.tools-tab {
  flex: 1;
  border: none;
  padding: 0.55rem 0.5rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tools-tab.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tools-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem 1.25rem;
}

.tools-pane {
  display: none;
}

.tools-pane.active {
  display: block;
  animation: toolFade 0.25s ease;
}

@keyframes toolFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tuner */
.tuner-display {
  text-align: center;
  padding: 1rem 0;
}

.tuner-note {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.tuner-string-label {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.tuner-freq {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.tuner-meter {
  position: relative;
  height: 12px;
  background: var(--section-bg);
  border-radius: 999px;
  margin: 1.25rem 0 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border);
}

.tuner-meter-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: translateX(-50%);
  z-index: 2;
}

.tuner-meter-needle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 8px;
  left: 50%;
  margin-left: -4px;
  background: #ec4899;
  border-radius: 4px;
  transform: translateX(-50%);
  transition: left 0.08s ease-out;
  z-index: 3;
}

.tuner-meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.tuner-cents {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  min-height: 1.5em;
}

.tuner-cents.in-tune {
  color: var(--success, #059669);
}

.tuner-cents.sharp {
  color: #dc2626;
}

.tuner-cents.flat {
  color: #2563eb;
}

.tuner-strings {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  margin: 1rem 0;
}

.tuner-string-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.5rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tuner-string-btn small {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
}

.tuner-string-btn.active {
  background: var(--accent-soft);
  border-color: #a5b4fc;
  color: var(--accent);
}

.tuner-string-btn.target {
  box-shadow: 0 0 0 2px var(--accent);
}

.tool-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.tool-btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  color: #fff;
}

.tool-btn--primary:hover {
  transform: scale(1.02);
}

.tool-btn--stop {
  background: #fee2e2;
  color: #dc2626;
}

.tool-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.75rem;
  line-height: 1.45;
}

/* Metronome */
.metro-bpm-display {
  text-align: center;
  margin: 0.5rem 0 1rem;
}

.metro-bpm-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.metro-bpm-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.metro-slider {
  width: 100%;
  margin: 0.5rem 0 1rem;
  accent-color: var(--accent);
}

.metro-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.metro-preset {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.metro-preset.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.metro-beat-visual {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
  min-height: 2.5rem;
  align-items: center;
}

.metro-beat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  transition: transform 0.1s, background 0.1s;
}

.metro-beat-dot.flash {
  background: var(--accent);
  transform: scale(1.35);
}

.metro-beat-dot.accent.flash {
  background: #ec4899;
}

body.tools-open {
  overflow: hidden;
}
