:root {
  --label-width: 108px;
  --step-size: 46px;
  --row-height: 34px;
  --app-radius: 0px;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-soft: rgba(249, 252, 255, 0.86);
  --ink: #1e355c;
  --soft-ink: #687998;
  --border: #dce8fb;
  --border-strong: #c5daf8;
  --blue: #2aa0df;
  --blue-dark: #157bc0;
  --danger: #ef6262;
  --danger-dark: #d94f4f;
  --playhead: rgba(76, 186, 255, 0.14);
  --shadow:
    0 30px 70px rgba(34, 73, 120, 0.12),
    0 10px 22px rgba(34, 73, 120, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: "Nunito", "Avenir Next Rounded", "Trebuchet MS", "Verdana", sans-serif;
  color: var(--ink);
  background: #ffffff;
  padding: 0;
}

body.grid-composer-page .shopify-section-group-header-group,
body.grid-composer-page #shopify-section-header,
body.grid-composer-page [id*="shopify-section"][id*="header"],
body.grid-composer-page .shopify-section-group-footer-group,
body.grid-composer-page #shopify-section-footer,
body.grid-composer-page [id*="shopify-section"][id*="footer"],
body.grid-composer-page [id*="shopify-section"][id*="announcement"] {
  display: none !important;
}

body.grid-composer-page #MainContent,
body.grid-composer-page main#MainContent {
  margin-top: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.shell {
  position: relative;
  background: #ffffff;
  border: 0;
  border-radius: var(--app-radius);
  overflow: visible;
}

.boot-loader {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  gap: 10px;
  background: rgba(251, 253, 255, 0.88);
  backdrop-filter: blur(4px);
  transition: opacity 0.18s ease;
}

.boot-loader.done {
  opacity: 0;
}

.boot-loader-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid #cfe0f8;
  border-top-color: var(--blue);
  animation: bootSpin 0.82s linear infinite;
}

.boot-loader-text {
  margin: 0;
  font-weight: 800;
  color: #4c6695;
}

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

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px 10px;
  position: relative;
  z-index: 30;
}

.settings-kicker,
.section-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  font-weight: 900;
  color: #5d88b8;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.composition-name {
  flex: 0 1 220px;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 0 2px;
  border-bottom: 2px solid #dbe6f8;
  font-size: clamp(1.22rem, 1.8vw, 1.6rem);
  font-weight: 900;
  color: #153563;
}

.composition-name:focus {
  outline: none;
  border-color: #7bd0ef;
}

.title-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
  z-index: 40;
}

.transport-cluster {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-btn,
.primary-btn,
.ghost-btn,
.choice-btn,
.stepper-btn,
.settings-done-btn {
  border-radius: 16px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease, background 0.14s ease;
}

.icon-btn:active,
.primary-btn:active,
.ghost-btn:active,
.choice-btn:active,
.stepper-btn:active,
.settings-done-btn:active {
  transform: translateY(2px);
  filter: brightness(0.98);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #fff;
}

.stop-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #fff;
}

.icon-btn,
.ghost-btn,
.primary-btn {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 900;
}

.icon-btn,
.ghost-btn {
  background: linear-gradient(180deg, #f8fbff, #edf4ff);
  color: #3a5a89;
  border: 2px solid #d5e3fa;
  box-shadow: 0 8px 18px rgba(86, 122, 180, 0.1);
}

.transport-icon-btn,
.ghost-btn,
.primary-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

.transport-icon-btn svg,
.ghost-btn svg,
.primary-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play-icon-btn {
  background: linear-gradient(180deg, #33afea, #1690d6);
  border: 2px solid #1690d6;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(39, 147, 212, 0.2);
}

.stop-icon-btn {
  background: linear-gradient(180deg, #fa7d72, #ef6262);
  border: 2px solid #ef6262;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(234, 98, 98, 0.18);
}

.icon-btn.is-active,
.choice-btn.is-active,
.split-btn.is-active {
  background: linear-gradient(180deg, #daf4ff, #c9ebff);
  border-color: #7bc9ee;
  color: #17629a;
}

.danger-btn {
  color: #9b3f3f;
  border-color: #f5cece;
  background: linear-gradient(180deg, #fff6f6, #ffe6e6);
}

.primary-btn {
  color: #fff;
  background: linear-gradient(180deg, #33afea, #1590d6);
  box-shadow: 0 8px 0 var(--blue-dark), 0 16px 26px rgba(39, 147, 212, 0.22);
}

.workspace {
  padding: 0 10px 8px;
}

.timeline-shell {
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
}

.timeline-ruler,
.grid-matrix {
  min-width: max-content;
}

.timeline-ruler {
  display: grid;
  grid-template-columns: var(--label-width) repeat(var(--steps, 1), var(--step-size));
  align-items: stretch;
  margin-bottom: 8px;
}

.ruler-label,
.ruler-step {
  min-height: 28px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.82rem;
  color: #5b7095;
}

.ruler-label {
  justify-items: start;
  padding-left: 14px;
}

.ruler-step {
  border-left: 1px solid rgba(120, 180, 236, 0.28);
  background: rgba(255, 255, 255, 0.82);
}

.ruler-step.is-beat {
  color: #2d5f9d;
  border-left-width: 2px;
  border-left-color: rgba(101, 154, 215, 0.55);
}

.ruler-step.is-bar {
  color: #1f4f8e;
  border-left-width: 4px;
  border-left-color: rgba(74, 161, 240, 0.92);
}

.ruler-step.is-subdivision-label {
  color: rgba(91, 112, 149, 0.5);
}

.ruler-step.is-alt-beat {
  background: rgba(222, 228, 236, 0.5);
}

.grid-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 6px;
  overscroll-behavior-x: contain;
}

.grid-stage {
  min-width: max-content;
}

.section-block {
  position: relative;
}

.grid-matrix {
  display: grid;
  gap: 6px;
}

.grid-row {
  display: grid;
  grid-template-columns: var(--label-width) repeat(var(--steps, 1), var(--step-size));
  align-items: stretch;
  min-height: var(--row-height);
}

.row-label {
  position: sticky;
  left: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  min-height: var(--row-height);
  margin-right: 6px;
  padding: 0 8px;
  border-radius: 12px;
  border: 0;
  background: var(--row-color, #8cc7ff);
  color: var(--row-text-color, #ffffff);
  font-weight: 900;
  text-align: center;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.08),
    8px 0 16px rgba(255, 255, 255, 0.92);
}

.row-label:hover {
  filter: brightness(1.03);
}

.row-pill-text {
  display: block;
  line-height: 1;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.row-label-low .row-pill-text {
  font-size: 1rem;
  font-weight: 1000;
}

.row-label-high .row-pill-text {
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: none;
}

.row-label-drum .row-pill-text {
  font-size: 0.78rem;
  font-weight: 900;
}

.grid-cell {
  position: relative;
  min-width: var(--step-size);
  min-height: var(--row-height);
  border-radius: 8px;
  border: 1px solid rgba(130, 184, 230, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 250, 255, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.76);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.grid-cell.is-alt-beat {
  background:
    linear-gradient(180deg, rgba(236, 240, 245, 0.96), rgba(228, 233, 240, 0.9));
}

.grid-cell::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  background: transparent;
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.grid-cell:hover::after {
  background: rgba(84, 178, 239, 0.08);
}

.grid-cell.is-active::after {
  background: var(--cell-color, #5bbdff);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.08),
    0 8px 12px color-mix(in srgb, var(--cell-color, #5bbdff) 36%, white 64%);
  transform: scale(0.96);
}

.grid-cell.is-playhead {
  background:
    linear-gradient(180deg, rgba(120, 212, 255, 0.18), rgba(104, 197, 255, 0.12)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 250, 255, 0.92));
}

.grid-cell.is-playhead.is-active::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  border: 2px solid rgba(65, 165, 236, 0.82);
}

.grid-cell.is-bar-start {
  border-left-width: 4px;
  border-left-color: rgba(74, 161, 240, 0.92);
}

.grid-cell.is-beat-start {
  border-left-width: 2px;
  border-left-color: rgba(101, 154, 215, 0.58);
}

.grid-divider {
  height: 1px;
  margin: 10px 0 8px;
  background: linear-gradient(90deg, transparent, rgba(151, 179, 221, 0.48), transparent);
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px 18px;
}

.tempo-block {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.tempo-label,
.tempo-value,
.footer-status {
  font-weight: 900;
}

.tempo-label {
  min-width: 58px;
  color: #3c5f8f;
}

.tempo-slider {
  flex: 1;
  accent-color: var(--blue);
}

.tempo-value {
  min-width: 88px;
  color: #1d73af;
}

.footer-status {
  color: var(--soft-ink);
  text-align: right;
}

.message {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  min-width: 180px;
  max-width: min(80vw, 460px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(24, 51, 88, 0.92);
  color: #fff;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 18px 34px rgba(24, 51, 88, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.message.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.saved-panel {
  position: absolute;
  right: 14px;
  top: calc(100% + 10px);
  width: min(460px, calc(100vw - 28px));
  max-height: min(54vh, 420px);
  overflow: auto;
  padding: 12px;
  border-radius: 20px;
  border: 2px solid #d8e5fb;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 44px rgba(43, 78, 126, 0.16);
  z-index: 120;
}

.saved-title {
  margin: 0 0 10px;
  font-size: 1rem;
  color: #285081;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid #e5eefc;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.saved-meta {
  display: grid;
  gap: 2px;
}

.saved-meta strong {
  color: #1c436f;
}

.saved-meta span {
  font-size: 0.84rem;
  color: var(--soft-ink);
}

.saved-actions {
  display: flex;
  gap: 8px;
}

.saved-actions button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 900;
  color: #335784;
  background: #eef5ff;
  border: 1px solid #d8e6fb;
}

.saved-actions button.delete-btn {
  color: #9a4040;
  background: #fff1f1;
  border-color: #f5d4d4;
}

.saved-empty {
  padding: 16px 10px;
  border-radius: 16px;
  background: #f7fbff;
  text-align: center;
  color: var(--soft-ink);
  font-weight: 800;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
}

.settings-scrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 48, 84, 0.2);
  backdrop-filter: blur(4px);
}

.settings-dialog {
  position: relative;
  width: min(1080px, 100%);
  padding: 28px 28px 34px;
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 32px 60px rgba(23, 48, 84, 0.2);
}

.settings-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #e2e8f3;
  color: #111;
  font-size: 2.1rem;
  line-height: 1;
}

.settings-header h2 {
  margin: 6px 0 0;
  font-size: clamp(1.8rem, 2.6vw, 2.4rem);
  color: #1f426f;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 30px;
  margin-top: 24px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 96px;
  border-bottom: 1px solid rgba(224, 232, 243, 0.9);
}

.setting-row-wide {
  grid-column: 1 / -1;
}

.setting-label {
  font-size: clamp(1.1rem, 1.9vw, 1.45rem);
  font-weight: 800;
  color: #616872;
}

.setting-value-wrap,
.setting-choice-group {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
}

.setting-value-text,
.setting-note {
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  font-weight: 800;
  color: #2aa0df;
  text-align: right;
}

.setting-note {
  max-width: 620px;
  font-size: 1rem;
  line-height: 1.4;
}

.setting-stepper {
  display: flex;
  gap: 10px;
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #fff;
  color: #2aa0df;
  border: 2px solid #e1e7f0;
  font-size: 2rem;
  line-height: 1;
}

.choice-btn {
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid #dce6f6;
  background: #fff;
  color: #597194;
  font-weight: 900;
}

.split-group .choice-btn {
  min-width: 56px;
}

.settings-done-btn {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin: 30px auto 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, #36ace9, #2197da);
  box-shadow: 0 16px 34px rgba(39, 147, 212, 0.28);
  font-size: 3.4rem;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .hero-bar,
  .footer-bar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .transport-cluster {
    justify-content: flex-start;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    padding: 0;
  }

  .hero-bar,
  .workspace,
  .footer-bar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .title-row {
    flex: 1 1 auto;
  }

  .title-actions {
    justify-content: flex-start;
  }

  .icon-btn,
  .primary-btn,
  .ghost-btn {
    min-height: 46px;
  }

  .settings-dialog {
    padding: 20px 18px 26px;
  }

  .settings-close {
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
  }

  .settings-done-btn {
    width: 108px;
    height: 108px;
    font-size: 2.7rem;
  }
}
