:root {
  --bg-top: #fff5df;
  --bg-bottom: #d7f0ff;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(47, 70, 94, 0.12);
  --text-main: #1f2a36;
  --text-muted: #5c6875;
  --accent: #ff7a59;
  --accent-deep: #ee5c38;
  --accent-soft: #ffd7ca;
  --step-off: #f4f7fb;
  --step-on: #0ea5a4;
  --step-on-glow: #7ce7e6;
  --step-current: #ffd166;
  --line-strong: #9dc7d8;
  --shadow: 0 24px 70px rgba(31, 42, 54, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Gowun Dodum", sans-serif;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  position: relative;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.background-glow {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.35;
  pointer-events: none;
}

.background-glow-a {
  top: -8rem;
  left: -6rem;
  background: #ffc9b7;
}

.background-glow-b {
  right: -8rem;
  bottom: -8rem;
  background: #9be6f7;
}

.app-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  display: grid;
  gap: 1.25rem;
}

.hero-card,
.composer-card,
.info-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card,
.info-card {
  padding: 1.5rem;
}

.composer-card {
  padding: 1.5rem;
}

.eyebrow,
.section-label {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--accent-deep);
}

.hero-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Baloo 2", cursive;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
}

.version-badge {
  flex-shrink: 0;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--text-muted);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

h3 {
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
}

.hero-copy,
.info-card p,
.learning-note span {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.hero-copy {
  margin-top: 0.9rem;
  max-width: 42rem;
}

.learning-note {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(47, 70, 94, 0.08);
  border-radius: 18px;
  display: grid;
  gap: 0.35rem;
}

.achievement-note {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.28rem;
  padding-left: 0.1rem;
  color: var(--text-muted);
}

.achievement-note strong {
  font-size: 0.84rem;
  color: var(--text-main);
}

.achievement-note span {
  font-size: 0.84rem;
  line-height: 1.55;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary-button,
.ghost-button {
  border: none;
  border-radius: 16px;
  min-height: 3.25rem;
  padding: 0.8rem 1.25rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white;
  box-shadow: 0 12px 28px rgba(238, 92, 56, 0.28);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
  border: 1px solid rgba(47, 70, 94, 0.12);
}

.primary-button:hover,
.ghost-button:hover,
.primary-button:focus-visible,
.ghost-button:focus-visible {
  transform: translateY(-1px);
}

.tempo-panel {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
}

.tempo-panel label,
.tempo-panel output {
  font-weight: 700;
}

.tempo-panel input {
  width: 100%;
  accent-color: var(--accent);
}

.save-share-panel {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(47, 70, 94, 0.08);
}

.save-share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 122, 89, 0.14);
  color: var(--accent-deep);
  font-weight: 700;
  white-space: nowrap;
}

.mode-badge.is-shared {
  background: rgba(14, 165, 164, 0.14);
  color: #0b7d7c;
}

.mode-message,
.save-feedback {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.pattern-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.pattern-name-field,
.slot-manager {
  display: grid;
  gap: 0.4rem;
  color: var(--text-main);
  font-weight: 700;
}

.pattern-name-field input,
.slot-controls select {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(47, 70, 94, 0.14);
  background: rgba(244, 247, 251, 0.96);
  color: var(--text-main);
}

.slot-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.6rem;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.share-preview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 220px;
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.share-link-field {
  display: grid;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.share-link-field input {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(47, 70, 94, 0.14);
  background: rgba(244, 247, 251, 0.96);
  color: var(--text-muted);
}

.qr-card {
  display: grid;
  gap: 0.6rem;
}

.qr-frame {
  min-height: 220px;
  border-radius: 18px;
  border: 1px solid rgba(47, 70, 94, 0.1);
  background: rgba(255, 255, 255, 0.8);
  display: grid;
  place-items: center;
  padding: 0.75rem;
}

#share-qr {
  width: 100%;
  max-width: 200px;
  height: auto;
  border-radius: 12px;
  display: block;
}

.qr-placeholder,
.qr-help {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.qr-placeholder {
  text-align: center;
  max-width: 12rem;
}

.grid-wrapper {
  margin-top: 1.2rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-gutter: stable;
}

.step-labels,
.grid-row {
  display: grid;
  grid-template-columns: 96px repeat(16, minmax(2.8rem, 1fr));
  gap: 0.45rem;
  min-width: 860px;
}

.step-labels {
  margin-bottom: 0.55rem;
}

.step-number,
.row-label {
  display: grid;
  place-items: center;
  min-height: 2.6rem;
  border-radius: 16px;
  color: var(--text-muted);
}

.step-number {
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.54);
}

.row-label {
  padding: 0 0.65rem;
  justify-content: start;
  font-weight: 700;
  color: var(--text-main);
}

.step-labels .row-label,
.grid-row .row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 10px 0 16px rgba(255, 255, 255, 0.82);
}

.step-labels .row-label {
  z-index: 3;
}

.sequencer-grid {
  display: grid;
  gap: 0.55rem;
}

.step-button {
  min-height: 3.25rem;
  border: none;
  border-radius: 16px;
  background: var(--step-off);
  box-shadow: inset 0 0 0 1px rgba(47, 70, 94, 0.08);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, box-shadow 0.16s ease;
  position: relative;
}

.step-button:hover,
.step-button:focus-visible {
  transform: scale(1.03);
}

.step-button.is-active {
  background: linear-gradient(180deg, var(--step-on-glow), var(--step-on));
  box-shadow: 0 0 0 2px rgba(14, 165, 164, 0.15), 0 10px 18px rgba(14, 165, 164, 0.18);
}

.step-button.is-current {
  box-shadow: inset 0 0 0 3px rgba(255, 209, 102, 0.96);
}

.step-button.is-current.is-active {
  box-shadow: inset 0 0 0 3px rgba(255, 244, 191, 0.96), 0 10px 20px rgba(14, 165, 164, 0.2);
}

.step-button.bar-start,
.step-number.bar-start {
  border-left: 4px solid var(--line-strong);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--text-muted);
}

.dot {
  width: 0.95rem;
  height: 0.95rem;
  display: inline-block;
  border-radius: 999px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.dot-active {
  background: var(--step-on);
}

.dot-current {
  background: var(--step-current);
}

.dot-bar {
  background: var(--line-strong);
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, 1120px);
    padding-top: 1rem;
  }

  .hero-card,
  .composer-card,
  .info-card {
    border-radius: 24px;
  }

  .hero-title-row {
    align-items: baseline;
    flex-wrap: wrap;
  }

  .toolbar,
  .tempo-panel,
  .save-share-header,
  .pattern-meta,
  .share-preview,
  .slot-controls {
    grid-template-columns: 1fr;
    display: grid;
    align-items: stretch;
  }

  .controls,
  .share-actions {
    width: 100%;
  }

  .qr-card {
    justify-items: stretch;
  }

  .primary-button,
  .ghost-button {
    flex: 1;
  }

  .grid-wrapper {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  .step-labels,
  .grid-row {
    grid-template-columns: 76px repeat(16, minmax(2.35rem, 1fr));
    gap: 0.35rem;
    min-width: 760px;
  }

  .step-number,
  .row-label {
    min-height: 2.25rem;
    border-radius: 12px;
  }

  .step-button {
    min-height: 2.9rem;
    border-radius: 14px;
  }
}
