:root {
  color-scheme: dark;
  --ink: #f8f2e8;
  --muted: #a39aa7;
  --panel: #1b1721;
  --panel-2: #241e2b;
  --line: rgba(248, 242, 232, 0.12);
  --acid: #c8ff4d;
  --coral: #ff5f57;
  --purple: #a484ff;
  --bg: #120f17;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 82% 8%, rgba(164, 132, 255, 0.12), transparent 28rem),
    linear-gradient(180deg, #16111b 0%, var(--bg) 40%);
  color: var(--ink);
  overscroll-behavior: none;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(28px + var(--safe-bottom));
}

.topbar, .track-heading, .section-heading, .time-row, .range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 { margin: 1px 0 0; font-size: 24px; letter-spacing: -0.04em; }
.dot { color: var(--acid); }
.eyebrow, .kicker {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.icon-button, .text-button, .transport-side, .pill-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 24px;
}
.text-button { padding: 8px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }

.import-screen { padding-top: clamp(30px, 8vh, 88px); }
.hero-mark { height: 62px; display: flex; align-items: end; gap: 7px; margin-bottom: 28px; }
.hero-mark span { width: 9px; background: var(--acid); border-radius: 6px; transform: skew(-8deg); }
.hero-mark span:nth-child(1) { height: 24px; }
.hero-mark span:nth-child(2) { height: 52px; }
.hero-mark span:nth-child(3) { height: 34px; }
.hero-mark span:nth-child(4) { height: 60px; }
.hero-mark span:nth-child(5) { height: 42px; }
.hero-copy h2 {
  margin: 5px 0 15px;
  max-width: 460px;
  font-size: clamp(45px, 13vw, 72px);
  line-height: 0.91;
  letter-spacing: -0.065em;
}
.hero-copy > p:last-child { max-width: 390px; color: var(--muted); line-height: 1.5; }

.url-form { margin-top: 44px; }
.url-form label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.input-row { display: flex; padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.input-row input { flex: 1; min-width: 0; padding: 12px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.input-row input::placeholder { color: #746b77; }
.arrow-button {
  flex: 0 0 48px;
  border: 0;
  border-radius: 13px;
  background: var(--acid);
  color: #17131b;
  font-size: 23px;
  font-weight: 900;
  cursor: pointer;
}
.field-note { margin: 9px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.import-actions { display: grid; gap: 8px; margin-top: 24px; }
.secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}
.secondary-button:disabled { opacity: 0.38; cursor: default; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.danger-button { border-color: rgba(255, 95, 87, 0.3); color: #ff8e88; }

.studio { padding-top: 38px; }
.track-heading h2 { margin: 3px 0 0; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 27px; }
.timeline {
  position: relative;
  height: 140px;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #211a27, #18141d);
  touch-action: none;
  cursor: ew-resize;
  user-select: none;
}
.timeline.is-scrubbing { cursor: grabbing; }
.waveform { position: absolute; inset: 18px 10px; display: flex; align-items: center; gap: 2px; opacity: 0.72; }
.wave-bar { flex: 1; min-width: 1px; border-radius: 2px; background: linear-gradient(180deg, #b6aabc, #665d69); }
.comp-overlay { position: absolute; inset: auto 0 8px; height: 7px; }
.comp-region { position: absolute; height: 100%; border-radius: 5px; background: var(--acid); box-shadow: 0 0 16px rgba(200, 255, 77, 0.35); }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--coral); pointer-events: none; }
.playhead span { position: absolute; top: 0; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); transform: translate(-50%, -40%); }
.punch-preview { position: absolute; top: 0; bottom: 0; background: rgba(200, 255, 77, 0.16); border-inline: 1px solid var(--acid); pointer-events: none; }
.time-row { margin: 10px 2px 0; color: var(--muted); font: 700 11px ui-monospace, monospace; }
.recording-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); letter-spacing: 0.1em; }
.recording-state.live { color: var(--coral); }
.mic-meter { display: inline-flex; align-items: end; gap: 2px; width: 24px; height: 13px; }
.mic-meter i {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: #514a54;
  transition: height 80ms linear, background-color 80ms linear, box-shadow 80ms linear;
}
.mic-meter i:nth-child(2) { height: 6px; }
.mic-meter i:nth-child(3) { height: 8px; }
.mic-meter i:nth-child(4) { height: 10px; }
.mic-meter i:nth-child(5) { height: 13px; }
.mic-meter i.active { background: var(--acid); box-shadow: 0 0 6px rgba(200, 255, 77, 0.5); }
.mic-meter i.hot { background: var(--coral); box-shadow: 0 0 6px rgba(255, 95, 87, 0.55); }

.transport { display: grid; grid-template-columns: 1fr 82px 1fr; align-items: center; margin: 26px auto 18px; max-width: 330px; }
.transport-side { padding: 18px; color: var(--muted); font-weight: 800; }
.play-button {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.play-button.is-playing { background: var(--coral); }
.play-symbol { margin-left: 4px; font-size: 25px; }
.play-button.is-playing .play-symbol { margin: 0; font-size: 0; }
.play-button.is-playing .play-symbol::after { content: "Ⅱ"; font-size: 26px; font-weight: 900; }

.punch-button {
  position: relative;
  width: 100%;
  min-height: 92px;
  padding: 18px 20px 16px 56px;
  border: 1px solid rgba(200, 255, 77, 0.25);
  border-radius: 22px;
  background: rgba(200, 255, 77, 0.055);
  text-align: left;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.punch-button:disabled { opacity: 0.35; cursor: default; }
.punch-button.is-punching { background: var(--acid); color: #151019; transform: scale(0.99); }
.punch-light { position: absolute; left: 22px; top: 28px; width: 16px; height: 16px; border: 4px solid var(--acid); border-radius: 50%; }
.is-punching .punch-light { border-color: var(--bg); background: var(--bg); }
.punch-label { display: block; font-size: 17px; font-weight: 900; letter-spacing: 0.07em; }
.punch-button small { display: block; margin-top: 3px; color: var(--muted); }
.is-punching small { color: rgba(21, 16, 25, 0.68); }

.take-section { margin-top: 38px; }
.section-heading h3 { margin: 3px 0 0; font-size: 24px; }
.section-heading h3 span { color: var(--muted); font-size: 14px; }
.pill-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.comp-history-bar { display: flex; gap: 8px; margin-top: 12px; }
.history-button { min-width: 92px; min-height: 42px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--ink); font-size: 17px; font-weight: 850; cursor: pointer; }
.history-button span { margin-left: 3px; font-size: 11px; }
.history-button:disabled { opacity: 0.3; cursor: default; }
.take-list { display: grid; gap: 10px; margin-top: 15px; }
.empty-takes { padding: 24px; border: 1px dashed var(--line); border-radius: 17px; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }
.take-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
}
.take-card-top { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.take-number { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--panel-2); color: var(--purple); font-weight: 900; }
.take-meta { min-width: 0; }
.take-meta strong { display: block; font-size: 13px; }
.take-meta span { display: block; overflow: hidden; color: var(--muted); font: 600 10px ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.take-actions { display: flex; gap: 5px; }
.take-actions button { min-width: 42px; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.take-card.is-current { border-color: rgba(255, 95, 87, 0.55); }
.pass-timeline {
  position: relative;
  height: 62px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(12.5% - 1px), rgba(248, 242, 232, 0.055) calc(12.5% - 1px), rgba(248, 242, 232, 0.055) 12.5%),
    #151119;
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.pass-vocal { position: absolute; inset-block: 9px; display: flex; align-items: center; gap: 1px; min-width: 2px; opacity: 0.78; pointer-events: none; }
.pass-vocal i { flex: 1; min-width: 1px; border-radius: 1px; background: var(--purple); }
.pass-regions { position: absolute; inset: 0; pointer-events: none; }
.pass-selected-region { position: absolute; inset-block: 0; border-inline: 1px solid var(--acid); background: rgba(200, 255, 77, 0.25); box-shadow: inset 0 -4px 0 var(--acid); }
.pass-playhead { position: absolute; inset-block: 0; left: 0; width: 1px; background: rgba(255, 95, 87, 0.82); pointer-events: none; }
.pass-selection-preview { position: absolute; inset-block: 0; border: 1px dashed var(--acid); background: rgba(200, 255, 77, 0.13); pointer-events: none; }
.take-timeline-hint { margin: 7px 2px 0; color: #746b77; font-size: 9px; font-weight: 700; letter-spacing: 0.04em; }
.export-section { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.export-note { grid-column: 1 / -1; margin: 0 4px; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: center; }

.sheet {
  width: min(calc(100% - 20px), 540px);
  margin: auto auto 0;
  padding: 12px 20px calc(28px + var(--safe-bottom));
  border: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  background: #1b1721;
  color: var(--ink);
}
.sheet::backdrop { background: rgba(5, 3, 7, 0.7); backdrop-filter: blur(5px); }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 22px; border-radius: 3px; background: #5d5561; }
.range-label { margin-top: 28px; font-size: 13px; font-weight: 700; }
.range-label output { color: var(--acid); font: 800 13px ui-monospace, monospace; }
input[type="range"] { width: 100%; margin: 18px 0 4px; accent-color: var(--acid); }
.setting-actions { display: grid; gap: 10px; margin-top: 30px; }
.take-alignment { margin-top: 22px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-2); }
.take-alignment > strong, .take-alignment > small { display: block; }
.take-alignment > strong { margin-top: 7px; font-size: 13px; }
.take-alignment small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.take-alignment .text-button { margin-top: 10px; color: var(--purple); font-size: 11px; font-weight: 750; }
.alignment-choice { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 11px; margin-top: 9px; cursor: pointer; }
.alignment-choice input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--acid); }
.alignment-choice strong, .alignment-choice small { display: block; }
.alignment-choice strong { font-size: 13px; line-height: 1.35; }
.take-menu-actions { display: grid; gap: 10px; margin-top: 24px; }
.take-menu-actions .secondary-button { display: flex; min-height: 58px; flex-direction: column; align-items: flex-start; text-align: left; }
.take-menu-actions .secondary-button span { font-weight: 800; }
.take-menu-actions .secondary-button small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 600; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  max-width: calc(100% - 36px);
  padding: 12px 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #2c2532;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: 180ms ease;
  pointer-events: none;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (min-width: 700px) {
  .app-shell { padding-inline: 0; }
  .sheet { margin-bottom: 20px; border-radius: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
