@font-face { font-family: Fredoka; src: url(../fonts/fredoka-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Fredoka; src: url(../fonts/fredoka-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --paper: #F6F0E4;
  --paper2: #EBE2D0;
  --ink: #1D1B22;
  --card: #FFFDF8;
  --red: #FF5B3A;
  --yellow: #FFC83D;
  --teal: #18A999;
  --blue: #3E7BFA;
  --pink: #FF86B4;
  --green: #69C24A;
  --bw: 3px;
  --shadow: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Fredoka, ui-rounded, system-ui, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(rgba(29, 27, 34, .09) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
:focus-visible { outline: 3px dashed var(--blue); outline-offset: 3px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; max-width: 1100px; margin: 0 auto; }
.topbar .grow { flex: 1; min-width: 0; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.7rem; letter-spacing: -.02em; transform: rotate(-1.5deg); }
.logo svg { width: 38px; height: 38px; }
.logo b { color: var(--red); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem; font-weight: 600; font-size: 1.02rem;
  background: var(--card); border: var(--bw) solid var(--ink); border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.yellow { background: var(--yellow); }
.btn.red { background: var(--red); }
.btn.teal { background: var(--teal); }
.btn.small { padding: .35rem .8rem; font-size: .92rem; }
.btn.icon { padding: .5rem; width: 44px; height: 44px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }

svg.i { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.page { max-width: 1100px; margin: 0 auto; padding: 8px 16px 48px; }
.page > h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.02em; margin: 8px 0 22px; }
.sub { margin: -14px 0 22px; opacity: .75; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 190px; padding: 18px 12px; text-align: center;
  background: var(--card); border: var(--bw) solid var(--ink); border-radius: 22px; box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.cards > :nth-child(odd) { transform: rotate(-1.2deg); }
.cards > :nth-child(even) { transform: rotate(1deg); }
button.card:hover { transform: rotate(0) translateY(-3px); box-shadow: 4px 7px 0 var(--ink); }
button.card:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.card.new { background: transparent; border-style: dashed; box-shadow: none; }
.card .name { font-weight: 600; font-size: 1.2rem; overflow-wrap: anywhere; }
.card .meta { font-size: .9rem; opacity: .7; }
.avatar {
  display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%;
  background: var(--c); border: var(--bw) solid var(--ink); font-weight: 600; font-size: 2.3rem;
}
.avatar.sm { width: 36px; height: 36px; font-size: 1.1rem; border-width: 2.5px; }
.plus { font-size: 3rem; line-height: 1; font-weight: 600; }
.cardwrap { position: relative; display: flex; }
.cardwrap > .card { flex: 1; }
.cardwrap > .x { position: absolute; top: -12px; right: -12px; width: 40px; height: 40px; }
.songstripe { display: flex; gap: 5px; height: 26px; align-items: stretch; }
.songstripe i { width: 18px; background: var(--c); border: 2.5px solid var(--ink); border-radius: 7px; }

.form { display: grid; gap: 18px; max-width: 460px; }
.form label { display: grid; gap: 8px; font-weight: 600; }
.text {
  padding: .7rem 1rem; font-size: 1.25rem; font-weight: 600; background: var(--card);
  border: var(--bw) solid var(--ink); border-radius: 16px; width: 100%;
}
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 48px; height: 48px; border-radius: 50%; background: var(--c); border: var(--bw) solid var(--ink); padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.note { font-size: .92rem; opacity: .7; margin-top: 28px; }

.studio { max-width: 1100px; margin: 0 auto; padding: 0 16px 170px; }
.song-name { background: transparent; border: 0; border-bottom: 3px dashed transparent; font-weight: 600; font-size: 1.5rem; width: 100%; padding: 4px 2px; min-width: 0; }
.song-name:hover, .song-name:focus { border-bottom-color: var(--ink); outline: 0; }

.empty {
  margin: 30px auto; max-width: 440px; text-align: center; padding: 26px 20px;
  background: var(--card); border: var(--bw) dashed var(--ink); border-radius: 22px;
}
.empty h2 { font-size: 1.5rem; margin-bottom: 6px; }
.empty p { margin: 0; opacity: .8; }

.track {
  background: var(--c); border: var(--bw) solid var(--ink); border-radius: 22px; box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 22px;
}
.track.muted { opacity: .55; }
.t-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.t-icon { display: grid; place-items: center; width: 40px; height: 40px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 12px; flex: none; }
.t-icon svg { width: 22px; height: 22px; }
.t-name { flex: 1 1 130px; min-width: 0; background: transparent; border: 0; border-bottom: 2.5px dashed transparent; font-weight: 600; font-size: 1.2rem; padding: 2px; }
.t-name:hover, .t-name:focus { border-bottom-color: var(--ink); outline: 0; }
.t-ctrl { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: .25rem .75rem; font-weight: 600; font-size: .92rem; background: var(--card); border: 2.5px solid var(--ink); border-radius: 999px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.mute[aria-pressed="true"] { background: var(--ink); color: var(--card); }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 30px; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 99px; }
input[type=range]::-moz-range-track { height: 8px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 99px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; }
.vol { width: 96px; }

.grid { display: flex; flex-wrap: wrap; gap: 10px; }
.half {
  flex: 1 1 300px; display: grid; grid-template-columns: 46px repeat(8, 1fr); gap: 4px; align-content: start;
  background: rgba(255, 253, 248, .55); border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px;
}
.lab { font-weight: 600; font-size: .72rem; padding: 0; background: var(--card); border: 2.5px solid var(--ink); border-radius: 9px; }
.cell { aspect-ratio: 1; min-height: 30px; padding: 0; background: var(--card); border: 2.5px solid var(--ink); border-radius: 9px; transition: transform .06s; }
.cell.g1 { background: #EDE5D3; }
.cell.on { background: var(--ink); }
.cell.now { transform: scale(1.1); background: #fff; }
.cell.on.now { background: var(--card); box-shadow: inset 0 0 0 5px var(--ink); }

.wave { position: relative; height: 100px; background: rgba(255, 253, 248, .55); border: 2.5px solid var(--ink); border-radius: 14px; overflow: hidden; }
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.playhead { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--ink); display: none; }
.tools { display: flex; justify-content: flex-end; margin-top: 8px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: var(--bw) solid var(--ink);
}
.play {
  display: grid; place-items: center; width: 68px; height: 68px; flex: none; border-radius: 50%;
  background: var(--teal); border: var(--bw) solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.play:active { transform: translate(4px, 4px); box-shadow: 0 0 0; }
.play.on { background: var(--red); }
.play svg { width: 32px; height: 32px; fill: currentColor; stroke: currentColor; }
.add { font-size: 1.15rem; padding: .8rem 1.4rem; }
.tempo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; }
.tempo input { width: 130px; }
.tempo output { min-width: 3.4ch; text-align: center; font-size: 1.1rem; }

.scrim { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(29, 27, 34, .45); }
.sheet {
  width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper); border: var(--bw) solid var(--ink); border-bottom: 0; border-radius: 26px 26px 0 0; animation: up .18s ease-out;
}
.sheet h2 { font-size: 1.5rem; margin-bottom: 14px; }
.choices { display: grid; gap: 12px; }
.choice { display: flex; align-items: center; gap: 14px; padding: 12px 14px; text-align: left; background: var(--c); border: var(--bw) solid var(--ink); border-radius: 20px; box-shadow: 3px 3px 0 var(--ink); }
.choice:active { transform: translate(3px, 3px); box-shadow: 0 0 0; }
.choice .t-icon { width: 54px; height: 54px; border-radius: 16px; }
.choice .t-icon svg { width: 30px; height: 30px; }
.choice b { display: block; font-size: 1.2rem; font-weight: 600; }
.choice span { font-size: .95rem; }
.tip { margin: 14px 2px 0; font-size: .92rem; opacity: .75; }
.row { display: grid; gap: 8px; margin-top: 8px; }

.rec { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; align-content: center; gap: 18px; padding: 24px; text-align: center; background: var(--paper); }
.rec.live { background: var(--red); }
.rec .big { font-size: clamp(5rem, 28vw, 11rem); line-height: 1; font-weight: 600; }
.rec h2 { font-size: clamp(1.6rem, 6vw, 2.4rem); }
.rec p { margin: 0; max-width: 34ch; }
.meter { width: min(420px, 90vw); height: 26px; background: var(--card); border: var(--bw) solid var(--ink); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); }
.progress { width: min(420px, 90vw); height: 14px; background: rgba(255, 253, 248, .6); border: var(--bw) solid var(--ink); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); width: 100%; transform-origin: left; transform: scaleX(0); }

#toast {
  position: fixed; left: 50%; bottom: 120px; z-index: 40; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(440px, calc(100% - 32px)); padding: .7rem 1.1rem; font-weight: 600; text-align: center;
  background: var(--yellow); border: var(--bw) solid var(--ink); border-radius: 16px; box-shadow: 3px 3px 0 var(--ink); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
.rec.live .big { animation: pulse .6s infinite; }
.rec:not(.live) .meter, .rec:not(.live) .progress { visibility: hidden; }

@media (max-width: 520px) {
  .dock { gap: 10px; }
  .tempo { order: 3; width: 100%; justify-content: center; }
  .tempo input { width: 55vw; }
  .vol { width: 80px; }
  #toast { bottom: 170px; }
  .studio { padding-bottom: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.error { margin: 0; min-height: 1.3em; color: #B3261E; font-weight: 600; }
.text.pin { max-width: 190px; text-align: center; letter-spacing: .5em; -webkit-text-security: disc; text-security: disc; }
.card.new svg { width: 46px; height: 46px; }

.syncrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 28px; }
#syncnote { font-size: .92rem; opacity: .75; }
