:root {
  --bg: #f4f4f5;
  --panel-bg: #ffffff;
  --accent: #2563eb;
  --accent-soft: #e5edff;
  --border: #d4d4d8;
  --text: #111827;
  --muted: #6b7280;
  --danger: #b91c1c;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e5e7eb, #f4f4f5 48%, #e5e7eb 100%);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 24px auto 32px;
  padding: 16px;
}

.app-header {
  text-align: center;
  margin-bottom: 16px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  font-family:Euphorigenic;
  letter-spacing: 0.03em;
}

/* Controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: flex-end;
  padding: 10px 14px 12px;
  margin-bottom: 12px;
  background: #f9fafb;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
}

.control-group.small {
  min-width: 90px;
  max-width: 96px;
}

.control-group label {
  font-size: 0.75rem;
  color: var(--muted);
}

select,
input[type="number"],
button {
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 6px 9px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

select:focus,
input[type="number"]:focus,
button:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* Scale panel */

.scale-panel {
  margin-bottom: 10px;
  padding: 10px 14px 8px;
  background: #fefefe;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.scale-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.panel-title {
  font-size: 0.88rem;
  font-weight: 600;
}

/* Edit mode toggle */

.edit-toggle {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e5e7eb;
  padding: 2px;
}

.edit-btn {
  border: none;
  background: transparent;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.edit-btn.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

/* Tone buttons */

.tone-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.tone-btn {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  border-width: 1px;
  border-style: solid;
  cursor: pointer;
  background: #ffffff;
  color: var(--muted);
  border-color: var(--border);
}

.tone-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.tone-btn.root {
  font-weight: 600;
}

.tone-btn.override-on {
  border-style: dashed;
}

.tone-btn.override-off {
  opacity: 0.4;
}

.tone-btn.extension {
  box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.45);
}

/* Scale panel footer */

.scale-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-top: 4px;
}

.scale-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.scale-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clear-btn {
  font-size: 0.75rem;
  padding: 5px 9px;
  background: #f9fafb;
  color: var(--muted);
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.clear-btn:hover {
  background: #eff6ff;
}

/* Export bar */

.export-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 10px 0 8px;
}

.export-bar button {
  cursor: pointer;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: #111827;
  color: #f9fafb;
  border: none;
}

.export-bar button:hover {
  background: #0f172a;
}

/* Canvas */

.canvas-wrapper {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px 14px;
}

.canvas-hint {
  margin: 0 0 4px 0;
  font-size: 0.78rem;
  color: var(--muted);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Responsive */

@media (max-width: 900px) {
  .app {
    margin-top: 12px;
  }

  .controls {
    padding: 8px 10px;
  }

  .control-group {
    min-width: 120px;
  }

  .canvas-wrapper {
    padding: 8px 8px 10px;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 10px;
  }

  .controls {
    flex-direction: column;
  }

  .control-group,
  .control-group.small {
    width: 100%;
    max-width: 100%;
  }

  .scale-panel-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .scale-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
