/* Song Maker Unlimited
   Mirrors the look of Chrome Music Lab's Song Maker: white canvas, sky blue
   grid, Quicksand title, Poppins labels, round outline buttons. */

:root {
  --blue: #16a8f0;
  --blue-soft: rgba(22, 168, 240, 0.12);
  --yellow: #f4a806;
  --red: #f03a3a;
  --text: #666;
  --ring: rgba(0, 0, 0, 0.1);
  --hairline: #f0f0f0;
  --topbar-h: 80px;
  --bottom-h: 110px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #fff;
  color: #000;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  font-family: "Poppins", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 8px; }

svg { display: block; }

/* ---------------- top bar ---------------- */

#topbar {
  position: relative;
  flex: none;
  height: var(--topbar-h);
  border-bottom: 1px solid #f5f5f5;
  box-shadow: rgba(0, 0, 0, 0.02) 1px 1px 1px 1px;
  z-index: 3;
  background: #fff;
}

#header-back {
  position: absolute;
  left: 20px;
  top: 20px;
  width: 40px;
  height: 41px;
  display: grid;
  place-items: center;
  color: #000;
}

#header-back svg { width: 24px; height: 24px; }

#gamepad-toggle {
  position: absolute;
  left: 74px;
  top: 21px;
  width: 34px;
  height: 35px;
  display: grid;
  place-items: center;
  color: #666;
  border-radius: 8px;
}

#gamepad-toggle svg { width: 28px; height: 28px; }
#gamepad-toggle[aria-pressed="true"] { color: var(--blue); }

/* viewer mode: same spot and size as the arrow pad toggle */
#mode-toggle {
  position: absolute;
  left: 116px;
  top: 21px;
  width: 34px;
  height: 35px;
  display: grid;
  place-items: center;
  color: #666;
  border-radius: 8px;
  transition: color 0.2s;
}

#mode-toggle svg { width: 26px; height: 26px; }
#mode-toggle[aria-pressed="true"] { color: var(--blue); }

#header-logo {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-family: "Quicksand", system-ui, sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 2px;
  white-space: nowrap;
}

#header-logo span { color: var(--blue); }

#toplinks {
  position: absolute;
  right: 26px;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 34px;
}

.header-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 12px;
  font-size: 18px;
  letter-spacing: 0.99px;
  color: var(--text);
}

.header-link .dot {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
}

.header-link .dot svg { width: 14px; height: 14px; }
.header-link .dot.blue { background: var(--blue); }
.header-link .dot.green { background: #6aa522; }
.header-link .dot.purple { background: #6c45d8; }
.header-link .dot.yellow { background: var(--yellow); font-size: 15px; font-weight: 400; line-height: 1; }

/* ---------------- tracks (optional) ---------------- */

#tracks {
  position: relative;
  flex: none;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid #f5f5f5;
  background: #fff;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  z-index: 2;
}

#tracks[hidden] { display: none; }
#tracks::-webkit-scrollbar { display: none; }

#track-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.track-chip {
  flex: none;
  display: flex;
  align-items: center;
  height: 46px;
  border: 2px solid #e6e6e6;
  border-radius: 23px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s, background-color 0.2s;
}

.track-chip.active {
  border-color: var(--blue);
  color: var(--blue);
}

.chip-main {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px 0 5px;
  border-radius: 21px;
  font-size: 15px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.track-chip.active .chip-main { padding-right: 6px; cursor: default; }

.chip-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--blue);
}

.chip-icon svg { width: 24px; height: 24px; }
.track-chip.active .chip-icon { background: var(--blue); color: #fff; }

.chip-badge {
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: #f2f2f2;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  color: #555;
}

.track-chip.muted .chip-icon,
.track-chip.muted .chip-name { opacity: 0.45; }

.chip-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

.chip-btn {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--blue);
  transition: background-color 0.2s, color 0.2s;
}

/* a full 44px touch target around the 34px circle */
.chip-btn::before {
  content: "";
  position: absolute;
  inset: -5px;
}

.chip-btn svg { width: 14px; height: 14px; }
.chip-btn[data-act="mute"] svg,
.chip-btn[data-act="delete"] svg { width: 20px; height: 20px; }
.chip-btn[data-act="mute"][aria-pressed="true"] { color: var(--red); }
.chip-btn.remove { color: #757575; }
.chip-btn:disabled { opacity: 0.3; cursor: default; }

.chip-split {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 2px;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: #757575;
  white-space: nowrap;
  cursor: text;
}

.chip-split-input {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 1.2ch;
  max-width: 8ch;
  font: inherit;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--blue);
  background: transparent;
  text-align: center;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.chip-split-input:focus { border-bottom: 2px solid var(--blue-soft); }

#track-add {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px dashed #cfcfcf;
  display: grid;
  place-items: center;
  color: var(--blue);
  transition: border-color 0.2s, background-color 0.2s;
}

#track-add svg { width: 22px; height: 22px; }
#track-add:disabled { opacity: 0.35; cursor: default; }
#track-add[hidden] { display: none; }

@media (hover: hover) {
  .track-chip:not(.active) .chip-main:hover { background: var(--blue-soft); }
  .chip-btn:not(:disabled):hover { background: var(--blue-soft); }
  #track-add:not(:disabled):hover { border-color: var(--blue); background: var(--blue-soft); }
}

/* ---------------- grid ---------------- */

#grid-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

/* Sizes and positions come from layout() in app.js, which follows the
   original's rules: tall enough rows, about four bars across, then scroll. */
.pane {
  position: absolute;
  left: 0;
  overflow: hidden;
}

#timeline { top: 0; }
#melody { top: 0; }

/* the timeline sets where Play starts */
#timeline canvas { cursor: pointer; }

/* repeats: the button at the timeline's right end, and each repeat's menu */
.timeline-tool {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 100%;
  display: grid;
  place-items: center;
  background: #fff;
  border-left: 1px solid #f0f0f0;
  color: #757575;
  transition: background-color 0.2s, color 0.2s;
}

.timeline-tool svg { width: 16px; height: 16px; }
.timeline-tool[aria-pressed="true"] { background: #6c45d8; color: #fff; }

.repeat-pop {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 16px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  font-size: 14px;
  letter-spacing: 0.3px;
  color: var(--text);
  white-space: nowrap;
}

.repeat-pop[hidden] { display: none; }
.repeat-what { margin-right: 6px; }

.repeat-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #e6e6e6;
  display: grid;
  place-items: center;
  color: #6c45d8;
}

.repeat-btn svg { width: 13px; height: 13px; }

.repeat-times {
  min-width: 34px;
  font-size: 17px;
  text-align: center;
  color: #6c45d8;
}

.repeat-remove {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  color: #757575;
}

@media (hover: hover) {
  .timeline-tool:hover { color: #6c45d8; }
  .timeline-tool[aria-pressed="true"]:hover { color: #fff; }
  .repeat-btn:hover { background: rgba(108, 69, 216, 0.08); }
  .repeat-remove:hover { color: var(--red); }
}

.pane canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* Scrollbars, styled like the original: a pale track with a blue pill. */
.scrollbar {
  position: absolute;
  z-index: 2;
  background: #fff;
  touch-action: none;
}

.scrollbar[hidden] { display: none; }

.scrollbar .track {
  position: absolute;
  border-radius: 20px;
  background: #f5f5f5;
  border: 1px solid #f5f5f5;
}

.scrollbar .thumb {
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
}

.scrollbar .thumb::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  background: var(--blue);
}

.scrollbar .thumb:hover::after,
.scrollbar.dragging .thumb::after { background: #57c1f9; }

.scrollbar.horizontal {
  left: 0;
  right: 41px;
  bottom: 0;
  height: 41px;
  border-top: 1px solid #f5f5f5;
}

.scrollbar.horizontal.full { right: 0; }
.scrollbar.horizontal .track { top: 8px; right: 12px; bottom: 8px; left: 12px; }
.scrollbar.horizontal .thumb { height: 100%; padding: 9px 13px; }

.scrollbar.vertical {
  top: 0;
  right: 0;
  width: 41px;
  height: 100%;
  border-left: 1px solid #f5f5f5;
}

.scrollbar.vertical .track { top: 12px; right: 8px; bottom: 12px; left: 8px; }
.scrollbar.vertical .thumb { width: 100%; padding: 13px 9px; }

/* Arrow pad (the original's "GamePad" menu) */
#gamepad {
  position: absolute;
  left: 16px;
  top: 44px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

#gamepad[hidden] { display: none; }

#gamepad button {
  border-radius: 50%;
  border: 1px solid var(--ring);
  display: grid;
  place-items: center;
  color: var(--blue);
  background: #fff;
}

#gamepad button:active { background: var(--blue-soft); }
#gamepad button svg { width: 20px; height: 20px; }
#gamepad [data-pad="up"] { grid-area: 1 / 2; }
#gamepad [data-pad="left"] { grid-area: 2 / 1; }
#gamepad [data-pad="enter"] { grid-area: 2 / 2; background: var(--blue); color: #fff; border-color: var(--blue); }
#gamepad [data-pad="right"] { grid-area: 2 / 3; }
#gamepad [data-pad="down"] { grid-area: 3 / 2; }

/* ---------------- bottom bar ---------------- */

#bottom {
  position: relative;
  flex: none;
  height: var(--bottom-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #fff;
  z-index: 3;
}

#bottom-left,
#bottom-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

#play-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--blue);
  display: grid;
  place-items: center;
  margin-right: 20px;
  align-self: center;
  transition: transform 0.12s;
}

#play-button:active { transform: scale(0.96); }
#play-button svg { width: 40px; height: 40px; }
#play-button .icon-stop { display: none; }
#play-button.playing .icon-play { display: none; }
#play-button.playing .icon-stop { display: block; }

.button {
  position: relative;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  letter-spacing: 0.82px;
  color: var(--text);
}

.button .ring {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--ring);
  display: grid;
  place-items: center;
  color: #666;
  background: #fff;
  transition: background-color 0.15s;
}

.button .ring svg { width: 30px; height: 30px; }
.button.instrument .ring { color: var(--blue); }
.button.instrument .ring svg { width: 34px; height: 34px; }
.button.instrument { min-width: 89px; }

@media (hover: hover) {
  .button:hover .ring { background: #f5f5f5; }
}

.button:disabled { cursor: default; opacity: 0.3; }
.button:disabled .ring { background: #fff; }

.button .label { white-space: nowrap; line-height: 1.4; }

/* save spinner */
#save-button.saving .ring::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* mic */
#mic-button.recording { color: var(--red); }
#mic-button.recording .ring { background: var(--red); border-color: var(--red); color: #fff; }

#mic-level {
  position: absolute;
  left: 50%;
  top: 30px;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  border-radius: 50%;
  border: 1px solid var(--red);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6);
}

#mic-button.recording #mic-level { opacity: 1; }

/* tempo */
#tempo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  padding: 0 24px;
}

#tempo label {
  font-size: 15px;
  letter-spacing: 0.66px;
  color: var(--text);
}

.range-wrap {
  position: relative;
  width: 304px;
  max-width: 100%;
  height: 28px;
}

.range-track,
.range-fill {
  position: absolute;
  left: 0;
  top: 10px;
  height: 8px;
  border-radius: 4px;
  pointer-events: none;
}

.range-track { right: 0; background: #f5f5f5; }
.range-fill { background: var(--blue); }

.range-wrap input[type="range"] {
  position: absolute;
  inset: -16px 0;
  width: 100%;
  height: 60px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.range-wrap input[type="range"]::-webkit-slider-runnable-track { height: 60px; background: transparent; }
.range-wrap input[type="range"]::-moz-range-track { height: 60px; background: transparent; }

.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: 14px;
  border-radius: 50%;
  background: var(--blue);
  border: 0;
}

.range-wrap input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  border: 0;
}

.range-wrap input[type="range"]:focus { outline: none; }
.range-wrap input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--blue-soft); }

#tempo-number {
  width: 44px;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.82px;
  color: var(--blue);
  background: transparent;
  text-align: left;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

#meter-button { display: none; }

/* ---------------- full screen modals ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: modal-in 0.18s ease-out;
}

.modal[hidden] { display: none; }

@keyframes modal-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  color: #000;
  z-index: 2;
}

.modal-close svg { width: 24px; height: 24px; }

.modal-body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 40px 60px;
}

/* settings */
.setting-columns {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 85px;
}

.setting-group {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--hairline);
}

.setting-group > label {
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--text);
  white-space: nowrap;
}

.setting-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.quantity {
  display: flex;
  align-items: center;
  min-width: 0;
}

.qty-value {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 1.2ch;
  max-width: 11ch;
  font: inherit;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--blue);
  background: transparent;
  text-align: right;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  -moz-appearance: textfield;
}

.qty-value:focus { border-bottom: 2px solid var(--blue-soft); }

.qty-text {
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--blue);
  white-space: nowrap;
  text-align: right;
}

.qty-unit {
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--blue);
  margin-left: 0.45em;
  white-space: nowrap;
}

.qty-btn {
  flex: none;
  width: 30px;
  height: 30px;
  margin-left: 10px;
  border-radius: 50%;
  border: 1px solid #e6e6e6;
  display: grid;
  place-items: center;
  color: var(--blue);
}

.qty-btn:first-of-type { margin-left: 20px; }
.qty-btn svg { width: 14px; height: 14px; }
.qty-btn:disabled { opacity: 0.35; cursor: default; }

@media (hover: hover) {
  .qty-btn:not(:disabled):hover { background: var(--blue-soft); }
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-wrap select {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--blue);
  padding: 4px 26px 4px 0;
  field-sizing: content;
  cursor: pointer;
  outline: none;
  text-align: right;
}

.select-wrap svg {
  position: absolute;
  right: 4px;
  width: 12px;
  height: 12px;
  color: #666;
  pointer-events: none;
}

.big-button {
  margin-top: 80px;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
}

.big-button svg { width: 66px; height: 66px; }

/* the optional extras switch, under the two columns of settings */
.setting-toggle {
  width: 100%;
  max-width: 1040px;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--hairline);
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.toggle-label {
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--text);
}

.toggle-hint {
  font-size: 14px;
  letter-spacing: 0.3px;
  line-height: 1.5;
  color: #757575;
}

.switch {
  position: relative;
  flex: none;
  width: 56px;
  height: 32px;
  border-radius: 16px;
  background: #e0e0e0;
  transition: background-color 0.2s;
}

.switch::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"] .knob { transform: translateX(24px); }

@media (prefers-reduced-motion: reduce) {
  .switch, .switch .knob, .track-chip, .chip-btn, #track-add, #mode-toggle { transition: none; }
}

.settings-note {
  margin: 28px 0 0;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: #9e9e9e;
  text-align: center;
}

/* save */
.save-title {
  margin: 0 0 44px;
  font-weight: 400;
  font-size: 32px;
  letter-spacing: 1px;
  color: var(--text);
  text-align: center;
}

.link-box {
  width: 500px;
  max-width: 100%;
  height: 124px;
  border: 2px solid #f2f2f2;
  display: flex;
  align-items: center;
  padding: 0 48px;
}

.link-box input {
  width: 100%;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 34px;
  letter-spacing: 1px;
  color: var(--text);
  background: transparent;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.copy-link {
  margin-top: 22px;
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--blue);
}

.save-options {
  margin-top: 64px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
}

.save-options button {
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  padding: 6px 0;
}

.save-options button:disabled { opacity: 0.5; cursor: progress; }

@media (hover: hover) {
  .copy-link:hover,
  .save-options button:not(:disabled):hover { color: var(--blue); }
}

/* import */
.import-hint {
  max-width: 560px;
  margin: -24px 0 28px;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.3px;
  color: var(--text);
  text-align: center;
}

.import-box {
  width: 560px;
  max-width: 100%;
  min-height: 132px;
  padding: 18px 22px;
  border: 2px solid #f2f2f2;
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
  resize: vertical;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.2s;
}

.import-box:focus { border-color: var(--blue-soft); }
.import-box::placeholder { color: #9e9e9e; }

.import-count {
  min-height: 24px;
  margin: 12px 0 0;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--blue);
}

.import-modes {
  width: 560px;
  max-width: 100%;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

.import-modes[hidden] { display: none; }

.import-modes legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--text);
}

.import-mode {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 14px;
  row-gap: 2px;
  align-items: center;
  min-height: 64px;
  padding: 12px 18px;
  border: 2px solid #f2f2f2;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.import-mode:has(input:checked) { border-color: var(--blue); background: rgba(22, 168, 240, 0.05); }
.import-mode:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

.import-mode input {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--blue);
}

.mode-title {
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--text);
}

.mode-hint {
  grid-column: 2;
  font-size: 14px;
  line-height: 1.45;
  color: #757575;
}

#import-submit { margin-top: 44px; }
#import-submit:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
#import-submit.busy { opacity: 0.6; cursor: progress; }

.import-status {
  min-height: 24px;
  max-width: 560px;
  margin: 24px 0 0;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.3px;
  color: var(--text);
  text-align: center;
  white-space: pre-line;
}

.import-results {
  width: 560px;
  max-width: 100%;
  margin-top: 12px;
  text-align: center;
}

.import-results[hidden] { display: none; }

.import-results ol {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  border-top: 1px solid var(--hairline);
}

.import-results li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--hairline);
  font-size: 15px;
  color: var(--text);
}

.import-results a { color: var(--blue); text-decoration: none; word-break: break-all; }
.import-results .failed { color: var(--red); }

@media (hover: hover) {
  .import-mode:not(:has(input:checked)):hover { border-color: #dcdcdc; }
  .import-results a:hover { text-decoration: underline; }
}

/* make songs with AI */
.ai-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 18px;
  padding: 10px 10px 10px 16px;
  border: 2px solid #f2f2f2;
}

.ai-copy code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}

.copy-mini {
  flex: none;
  min-width: 64px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--blue);
  transition: background-color 0.2s;
}

@media (hover: hover) {
  .copy-mini:hover { background: var(--blue-soft); }
}

.ai-legal {
  font-size: 14px;
  line-height: 1.6;
  color: #757575;
}

/* the Make with AI dialog */
.ai-guide {
  width: 640px;
  max-width: 100%;
  color: var(--text);
}

.ai-guide .save-title { margin-bottom: 14px; }

.ai-lead {
  margin: 0 0 30px;
  text-wrap: balance;
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
}

.ai-way {
  margin-bottom: 22px;
  padding: 22px 24px 8px;
  border: 2px solid #f2f2f2;
}

.ai-way h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.5px;
  color: #333;
}

.ai-way p {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.6;
}

.ai-badge {
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--blue);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
}

.ai-steps {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.ai-steps li {
  position: relative;
  min-height: 30px;
  margin-bottom: 10px;
  padding: 3px 0 0 44px;
  font-size: 16px;
  line-height: 1.6;
  counter-increment: step;
}

.ai-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 15px;
  line-height: 30px;
  text-align: center;
}

.ai-small {
  font-size: 14px;
  color: #757575;
}

.ai-guide .ai-legal { margin-top: 8px; text-align: center; }

/* about */
.about {
  max-width: 760px;
  width: 100%;
  font-size: 18px;
  line-height: 1.65;
  letter-spacing: 0.4px;
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}

.about h2 {
  margin: 0 0 24px;
  font-family: "Quicksand", system-ui, sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 2px;
  color: #000;
}

.about h2 span { color: var(--blue); }

.about h3 {
  margin: 40px 0 12px;
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #9e9e9e;
}

.about p { margin: 0 0 16px; }
.about a { color: var(--blue); text-decoration: none; }
.about a:hover { text-decoration: underline; }

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

.about li {
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}

.about li:last-child { border-bottom: 0; }

.about .limits {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0 28px;
  margin: 8px 0 0;
  font-size: 16px;
}

.about .limits div {
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}

.about .limits .head {
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #9e9e9e;
}

.about .limits .new { color: var(--blue); }

/* loading + toast */
#loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #fff;
  display: grid;
  place-items: center;
}

#loading[hidden] { display: none; }

#loading .spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid #f2f2f2;
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-h) + 20px);
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 12px);
  padding: 12px 20px;
  border-radius: 99px;
  background: rgba(40, 40, 40, 0.92);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.4px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: opacity 0.2s, transform 0.2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

#toast button {
  flex: none;
  color: #7fd0f8;
  font-size: 14px;
}

/* ---------------- smaller screens ---------------- */

/* The top right links only show their words where there is room beside the
   centered logo: all four on wide screens, then Restart and About, then none. */
@media (max-width: 1499px) {
  #header-ai .text, #header-import .text { display: none; }
}

@media (max-width: 1099px) {
  .header-link .text { display: none; }
}

@media (max-width: 1100px) {
  .range-wrap { width: 220px; }
  #bottom-right { gap: 2px; }
  .button { min-width: 72px; }
}

@media (max-width: 900px) {
  :root { --bottom-h: 96px; }
  #tempo { display: none; }
  #meter-button { display: flex; }
  #play-button { width: 64px; height: 64px; margin-right: 8px; }
  #play-button svg { width: 32px; height: 32px; }
  .button { min-width: 64px; font-size: 13px; letter-spacing: 0.5px; }
  .button .ring { width: 52px; height: 52px; }
  .button.instrument { min-width: 72px; }
  .button .ring svg { width: 26px; height: 26px; }
  .button.instrument .ring svg { width: 30px; height: 30px; }
  #mic-level { top: 26px; }

  /* tempo pops up above the bar, like the original's mobile meter */
  #tempo.open {
    display: flex;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 8px);
    padding: 14px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  }

  #tempo.open .range-wrap { flex: 1; width: auto; }
}

@media (max-width: 767px) {
  :root { --topbar-h: 56px; }
  #header-back { left: 8px; top: 8px; }
  #gamepad-toggle { left: 52px; top: 10px; }
  #mode-toggle { left: 90px; top: 10px; }
  #tracks { height: 58px; padding: 0 12px; gap: 8px; }
  #track-list { gap: 8px; }
  .setting-toggle { min-height: 88px; }
  .toggle-label { font-size: 16px; }
  .toggle-hint { font-size: 13px; }
  #header-logo { font-size: 15px; letter-spacing: 1.5px; }
  #toplinks { right: 12px; gap: 14px; }
  .import-hint { margin-top: -16px; font-size: 15px; }
  .header-link .text { display: none; }
  .header-link .dot { width: 28px; height: 28px; }
  .header-link .dot svg { width: 16px; height: 16px; }

  .setting-columns { grid-template-columns: 1fr; }
  .setting-group { min-height: 76px; }
  .setting-group > label { font-size: 16px; }
  .qty-value, .qty-text, .qty-unit, .select-wrap select { font-size: 18px; }
  .big-button { margin-top: 48px; width: 96px; height: 96px; }
  .big-button svg { width: 46px; height: 46px; }
  .modal-body { padding: 88px 20px 48px; }
  .modal-close { top: 12px; right: 12px; width: 48px; height: 48px; }
  .save-title { font-size: 24px; }
  .link-box { height: 88px; padding: 0 22px; }
  .link-box input { font-size: 22px; }
  .copy-link { font-size: 21px; }
  .save-options button { font-size: 15px; }
  .about { font-size: 16px; }
}

@media (max-width: 620px) {
  :root { --bottom-h: 74px; }
  #bottom { padding: 0 10px; }
  #bottom-left, #bottom-right { gap: 0; }
  #play-button { width: 52px; height: 52px; margin-right: 4px; }
  #play-button svg { width: 26px; height: 26px; }
  .button, .button.instrument { min-width: 0; width: 44px; }
  .button .label { display: none; }
  .button .ring { width: 42px; height: 42px; }
  .button .ring svg { width: 22px; height: 22px; }
  .button.instrument .ring svg { width: 26px; height: 26px; }
  #mic-level { top: 21px; width: 76px; height: 76px; margin: -38px 0 0 -38px; }
  #header-logo { font-size: 13px; letter-spacing: 1px; gap: 0.4em; }
}

@media (max-width: 440px) {
  #header-logo span { display: none; }
  #toplinks { gap: 8px; }
  .header-link .dot { width: 26px; height: 26px; }
  .header-link .dot svg { width: 15px; height: 15px; }
  .ai-way { padding: 18px 16px 4px; }
  .ai-lead { font-size: 16px; }
}

@media (max-width: 380px) {
  #gamepad-toggle { display: none; }
  #toplinks { gap: 6px; right: 10px; }
  .header-link .dot { width: 24px; height: 24px; }
  #header-logo { font-size: 12px; letter-spacing: 0.5px; }
}

@media (max-width: 340px) {
  #toplinks { gap: 4px; }
  .header-link .dot { width: 22px; height: 22px; }
  #header-logo { font-size: 11px; letter-spacing: 0; }
  #mode-toggle { left: 52px; }
  .button, .button.instrument { width: 40px; }
  .button .ring { width: 38px; height: 38px; }
}
