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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: #0e0e14;
  color: #c8c8d8;
  line-height: 1.7;
  overflow-x: hidden;
}

#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Header ---- */
header {
  padding: 40px 0 24px;
  text-align: center;
}

.back-link {
  display: inline-block;
  color: #7c6cff;
  background: rgba(124, 108, 255, 0.1);
  border: 1px solid rgba(124, 108, 255, 0.35);
  border-radius: 20px;
  padding: 5px 14px;
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 12px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.back-link:hover {
  background: rgba(124, 108, 255, 0.22);
  border-color: #7c6cff;
  color: #a090ff;
}

header h1 {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: #7c6cff;
  margin-bottom: 12px;
}

header p {
  color: #8888a0;
  font-size: 0.95rem;
  max-width: 480px;
  margin: 0 auto;
}

/* ---- Disclaimer ---- */
.disclaimer {
  background: transparent;
  border: 1px solid #c0392b;
  color: #c8c8d8;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.disclaimer strong {
  color: #e05050;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid #1e1e2a;
  border-bottom: 1px solid #1e1e2a;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-wrap {
  display: flex;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: #8888a0;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.toggle-btn.active {
  background: #7c6cff;
  color: #fff;
}

.toggle-btn:hover:not(.active) {
  background: #1e1e2a;
  color: #c8c8d8;
}

.action-btn {
  background: #1e1e2a;
  border: 1px solid #2a2a3a;
  color: #c8c8d8;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.action-btn:hover:not(:disabled) {
  background: #2a2a3a;
  border-color: #7c6cff;
}

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

.export-btn {
  background: #7c6cff;
  border-color: #7c6cff;
  color: #fff;
}

.export-btn:hover:not(:disabled) {
  background: #6b5ce0;
  border-color: #6b5ce0;
}

.small-btn {
  background: #1e1e2a;
  border: 1px solid #2a2a3a;
  color: #c8c8d8;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.small-btn:hover {
  background: #2a2a3a;
}

/* ---- Tuning Row ---- */
.tuning-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #1e1e2a;
}

.tuning-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.tuning-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: #8888a0;
}

.tuning-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tuning-select {
  background: #1e1e2a;
  border: 1px solid #2a2a3a;
  color: #c8c8d8;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.ref-pitch-label {
  margin-left: auto;
  color: #8888a0;
}

.ref-pitch-input {
  width: 70px;
  text-align: right;
}

.tuning-select:focus {
  outline: none;
  border-color: #7c6cff;
}

/* ---- Piano Roll ---- */
.piano-roll-wrap {
  position: relative;
  margin: 16px 0;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  overflow: hidden;
  background: #12121c;
  height: 500px;
}

#piano-roll {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ---- String Popup ---- */
.string-popup {
  position: absolute;
  background: #1e1e2a;
  border: 1px solid #3a3a4f;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.string-popup[hidden] {
  display: none;
}

.string-popup button {
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: filter 0.15s;
}

.string-popup button:hover {
  filter: brightness(1.25);
}

/* ---- Instructions ---- */
.instructions {
  padding: 24px 0;
  border-top: 1px solid #1e1e2a;
}

.instructions h2 {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: #7c6cff;
  margin-bottom: 16px;
}

.instructions ul {
  list-style: none;
  padding: 0;
}

.instructions li {
  padding: 5px 0;
  padding-left: 20px;
  position: relative;
  font-size: 0.9rem;
  color: #8888a0;
}

.instructions li::before {
  content: '>';
  position: absolute;
  left: 0;
  color: #7c6cff;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.55rem;
  top: 9px;
}

.instructions strong {
  color: #c8c8d8;
}

/* ---- Status bar ---- */
.status-bar {
  padding: 8px 0;
  font-size: 0.8rem;
  color: #44445a;
}

/* ---- Footer ---- */
footer {
  padding: 40px 0 30px;
  border-top: 1px solid #1e1e2a;
  text-align: center;
}

footer p {
  color: #44445a;
  font-size: 0.8rem;
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
  .page {
    padding: 0 12px;
  }

  header {
    padding: 24px 0 16px;
  }

  .piano-roll-wrap {
    height: 350px;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
