:root {
  color-scheme: dark;
  --ink: #f3f0e7;
  --muted: #aaa99f;
  --bg: #11120f;
  --panel: #1a1b17;
  --line: rgba(243, 240, 231, 0.14);
  --acid: #dfff54;
  --orange: #ff7548;
  --cyan: #5de0d3;
  --pink: #ed74a9;
  --blue: #7299f7;
  --yellow: #f6cb57;
  --green: #78d889;
  font-family: "SFMono-Regular", "Roboto Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 8%, rgba(223, 255, 84, 0.08), transparent 22rem),
    radial-gradient(circle at 3% 40%, rgba(93, 224, 211, 0.05), transparent 26rem),
    var(--bg);
  overflow-x: hidden;
}

button, select, input { font: inherit; }
button { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }

.masthead {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--acid);
  color: #10110e;
  font-size: 20px;
  transform: rotate(-8deg);
}

.status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(255,117,72,.12); }
.status.awake .status-dot { background: var(--acid); box-shadow: 0 0 0 4px rgba(223,255,84,.12); }

.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  align-items: center;
  gap: 30px;
  padding: 70px 0 74px;
}

.eyebrow, .section-kicker { color: var(--acid); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }

h1, h2, p { margin-top: 0; }
h1 {
  margin: 18px 0 22px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(58px, 7.3vw, 104px);
  line-height: 1.04;
  letter-spacing: -0.07em;
  font-weight: 900;
}

h1 em { color: var(--acid); font-family: "Kaiti SC", "STKaiti", "KaiTi", cursive; font-style: normal; font-weight: 700; letter-spacing: -0.02em; }

.intro { max-width: 590px; color: var(--muted); line-height: 1.9; font-size: 14px; }

.orb-stage { position: relative; min-height: 340px; display: grid; place-items: center; }
.sound-orb {
  position: relative;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(223,255,84,.5);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(223,255,84,.28), transparent 35%), #171912;
  box-shadow: 0 0 80px rgba(223,255,84,.08), inset 0 0 45px rgba(223,255,84,.04);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.sound-orb.playing { transform: scale(1.035); box-shadow: 0 0 90px rgba(223,255,84,.2), inset 0 0 45px rgba(223,255,84,.08); }
.sound-orb canvas { width: 100%; height: 100%; }
.sound-orb span { position: absolute; bottom: 34px; left: 0; right: 0; text-align: center; color: var(--acid); font-size: 9px; letter-spacing: .35em; }
.orbit { position: absolute; border: 1px solid var(--line); border-radius: 50%; animation: orbit 22s linear infinite; }
.orbit::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); top: 18%; right: 3%; }
.orbit-one { width: 310px; height: 310px; }
.orbit-two { width: 370px; height: 260px; transform: rotate(58deg); animation-direction: reverse; animation-duration: 28s; }
.orbit-two::after { background: var(--cyan); }

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

.studio, .composer { border: 1px solid var(--line); background: rgba(26,27,23,.78); backdrop-filter: blur(18px); }
.studio { padding: 38px; }
.panel-top, .composer-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.section-kicker { margin-bottom: 10px; }
h2 { margin-bottom: 0; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.04em; }

.control-row { display: flex; gap: 10px; }
.select-wrap { min-width: 188px; display: grid; gap: 7px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.select-wrap.compact { min-width: 98px; }
select {
  appearance: none;
  color: var(--ink);
  padding: 11px 34px 11px 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #12130f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23f3f0e7'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 12px;
}

.keys { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 36px; }
.note-key {
  --note-color: var(--acid);
  position: relative;
  min-width: 0;
  height: 184px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 18px;
  border: 1px solid var(--line);
  background: #12130f;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.note-key::before { content: ""; position: absolute; inset: auto -25% -65% -25%; height: 100%; border-radius: 50%; background: var(--note-color); filter: blur(18px); opacity: .12; transition: opacity .2s ease, transform .2s ease; }
.note-key:hover { transform: translateY(-5px); border-color: var(--note-color); }
.note-key:hover::before, .note-key.active::before { opacity: .48; transform: translateY(-18%); }
.note-key.active { transform: translateY(3px) scale(.985); border-color: var(--note-color); background: color-mix(in srgb, var(--note-color) 11%, #12130f); }
.note-key strong { position: relative; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(22px, 3vw, 34px); }
.note-key small { position: relative; margin-top: 5px; color: var(--note-color); }
.key-shortcut { position: absolute; top: 12px; right: 12px; color: var(--muted); font-size: 10px; }
.note-do { --note-color: var(--orange); }
.note-re { --note-color: var(--yellow); }
.note-mi { --note-color: var(--green); }
.note-fa { --note-color: var(--cyan); }
.note-sol { --note-color: var(--blue); }
.note-la { --note-color: var(--pink); }
.note-si { --note-color: var(--acid); }
.keyboard-hint { margin: 20px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
kbd { padding: 2px 5px; border: 1px solid var(--line); color: var(--ink); background: #11120f; box-shadow: 0 2px 0 #050505; }

.composer { margin-top: 18px; padding: 38px; }
.transport { display: flex; align-items: center; gap: 24px; }
.icon-button, .export-button, .text-button { border: 0; cursor: pointer; }
.icon-button { height: 48px; min-width: 118px; padding: 0 18px; display: flex; align-items: center; justify-content: center; gap: 11px; background: var(--acid); color: #11120f; font-weight: 500; }
.icon-button:hover, .export-button:hover { filter: brightness(1.08); }
.play-icon { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; }
.icon-button.is-playing .play-icon { width: 9px; height: 11px; border: 0; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.tempo-control { min-width: 195px; display: grid; gap: 8px; color: var(--muted); font-size: 10px; }
.tempo-control output { color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--acid); }

.sequencer-wrap { margin-top: 34px; overflow-x: auto; padding-bottom: 8px; }
.sequencer { min-width: 850px; display: grid; grid-template-columns: 42px repeat(16, 1fr); gap: 5px; }
.row-label { display: grid; place-items: center; color: var(--muted); font-size: 10px; }
.step {
  aspect-ratio: 1;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #12130f;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.step:hover { border-color: var(--note-color); transform: scale(.92); }
.step.active { background: var(--note-color); border-color: var(--note-color); box-shadow: inset 0 0 0 3px rgba(17,18,15,.2); }
.step.current { outline: 2px solid var(--ink); outline-offset: 2px; }
.step:nth-child(4n + 2) { border-left-color: rgba(243,240,231,.35); }

.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.text-button { padding: 10px 13px; color: var(--muted); background: transparent; border-bottom: 1px solid var(--line); font-size: 11px; }
.text-button:hover { color: var(--ink); border-color: var(--ink); }
.text-button.danger:hover { color: var(--orange); border-color: var(--orange); }
.export-button { display: flex; align-items: center; justify-content: space-between; gap: 38px; padding: 14px 16px; background: var(--ink); color: #11120f; min-width: 172px; font-weight: 500; }
.export-button:disabled { opacity: .5; cursor: wait; }
.arrow { font-size: 18px; }

footer { min-height: 160px; display: flex; align-items: center; justify-content: space-between; gap: 30px; color: var(--muted); font-size: 11px; }
.footer-mark { margin: 0; text-align: right; letter-spacing: .1em; }
footer > p:first-child { margin: 0; font-family: "Kaiti SC", "STKaiti", "KaiTi", cursive; color: var(--ink); font-size: 23px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translate(-50%, 20px); padding: 12px 18px; color: #11120f; background: var(--acid); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 680px); }
  .hero { grid-template-columns: 1fr; padding: 55px 0; }
  .orb-stage { display: none; }
  .panel-top, .composer-head { align-items: flex-start; flex-direction: column; }
  .control-row { width: 100%; }
  .select-wrap { flex: 1; }
  .keys { grid-template-columns: repeat(7, minmax(72px, 1fr)); overflow-x: auto; padding-bottom: 10px; }
  .note-key { height: 150px; }
  .transport { width: 100%; justify-content: space-between; }
}

@media (max-width: 560px) {
  .masthead { height: 72px; }
  .status { display: none; }
  .hero { min-height: 390px; }
  h1 { font-size: clamp(50px, 15vw, 74px); }
  .studio, .composer { padding: 24px 18px; margin-left: -7px; margin-right: -7px; }
  .control-row, .transport { align-items: stretch; flex-direction: column; }
  .select-wrap, .select-wrap.compact, .tempo-control { width: 100%; min-width: 0; }
  .icon-button { width: 100%; }
  .composer-actions { align-items: stretch; flex-direction: column; }
  .secondary-actions { justify-content: center; }
  .export-button { width: 100%; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; }
  .footer-mark { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
