:root {
  --bg: #f9f6f1;
  --paper: #fff;
  --raised: #f2ece5;
  --ink: #241f1c;
  --muted: #675d55;
  --soft: #998f87;
  --accent: #e0574f;
  --accent-dark: #a43d37;
  --accent-soft: #f8e4e0;
  --line: rgba(36, 31, 28, .12);
  --shadow: 0 28px 75px rgba(66, 42, 29, .12);
  --display: "Avenir Next", "SF Pro Rounded", ui-rounded, sans-serif;
  --body: "Avenir Next", "SF Pro Text", ui-rounded, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, monospace;
  --page: min(1440px, calc(100vw - 48px));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { color: #fff; background: var(--accent); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 246, 241, .9);
  backdrop-filter: blur(18px);
}
.nav {
  width: var(--page);
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 780;
  letter-spacing: -.025em;
}
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.nav-actions { display: flex; align-items: center; gap: 24px; }
.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.local-badge span { width: 7px; height: 7px; border-radius: 50%; background: #3b9d6d; box-shadow: 0 0 0 5px rgba(59, 157, 109, .12); }
.nav-link { color: var(--muted); font-size: 13px; font-weight: 700; }
.app-link {
  min-height: 42px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

main { width: var(--page); margin: 0 auto; }
.intro { max-width: 860px; padding: 78px 0 52px; }
.eyebrow {
  margin: 0 0 20px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, p { text-wrap: pretty; }
h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(50px, 6.5vw, 86px);
  line-height: 1;
  letter-spacing: -.064em;
}
.intro > p:last-child {
  max-width: 700px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.65;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.setup-panel {
  padding: 34px;
  border-right: 1px solid var(--line);
  background: #f5f0e9;
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
}
.panel-number {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
}
.panel-heading h2, .workspace-header h2 {
  margin: -5px 0 2px;
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: -.035em;
}
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.audio-drop {
  min-height: 76px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .72);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.audio-drop:hover, .audio-drop.is-dragging { border-color: var(--accent); background: var(--paper); transform: translateY(-2px); }
.audio-drop.has-file { border-style: solid; border-color: rgba(224, 87, 79, .45); background: var(--accent-soft); }
.audio-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.source-index {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 750;
}
.source-copy { min-width: 0; flex: 1; }
.source-copy small, .source-copy strong { display: block; }
.source-copy small { margin-bottom: 3px; color: var(--soft); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.source-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.source-action { color: var(--accent-dark); font-size: 11px; font-weight: 800; }
.input-heading { margin: 24px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.input-heading > label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 800; }
.input-heading-actions { display: flex; align-items: center; gap: 13px; }
.text-button {
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.text-button.danger { color: #a74a44; }
textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  font-size: 14px;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(224, 87, 79, .1); }
.setup-actions { margin-top: 12px; display: grid; grid-template-columns: 1fr; gap: 10px; }
.button {
  min-height: 48px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px;
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.button.primary { color: white; background: var(--ink); }
.button.secondary { border-color: var(--line); color: var(--ink); background: var(--paper); }
.button.compact { min-height: 44px; }
.button.stamp { min-height: 52px; color: white; background: var(--accent); }
.button.stamp kbd {
  min-width: 23px;
  height: 23px;
  margin-left: 12px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.setup-note { margin: 14px 0 0; color: var(--soft); font-size: 11px; line-height: 1.55; }

.timing-panel { min-width: 0; padding: 34px 38px 38px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.workspace-header > div:first-child { display: flex; align-items: baseline; gap: 14px; }
.project-status { display: flex; align-items: center; gap: 12px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.status-separator { width: 3px; height: 3px; border-radius: 50%; background: var(--soft); }
.player-stage { margin-top: 24px; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: #fcfaf7; }
.track-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.track-meta > div { min-width: 0; }
.track-label { display: block; margin-bottom: 5px; color: var(--soft); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.track-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.speed-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; font-weight: 750; }
.speed-control select { min-height: 38px; padding: 0 28px 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.waveform-wrap { position: relative; height: 198px; margin-top: 20px; overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fcfaf7; }
.timeline-scroll {
  position: absolute;
  inset: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-x;
}
.timeline-scroll::-webkit-scrollbar { display: none; }
.timeline-scroll.is-scrubbing { cursor: grabbing; }
.timeline-track { position: relative; height: 100%; min-width: 100%; }
.timeline-content { position: absolute; top: 0; left: var(--timeline-inset, 50%); width: var(--timeline-width, 100%); height: 100%; }
#timeline-ruler { width: 100%; height: 42px; display: block; }
#waveform { width: 100%; height: 124px; display: block; }
.timeline-playhead {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(255,255,255,.36);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-1px);
}
.timeline-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(109,43,38,.22);
  transform: translate(-50%, -1px);
}
.waveform-wrap.has-audio .timeline-playhead { opacity: 1; }
.waveform-empty { position: absolute; z-index: 3; inset: 42px 0 32px; display: grid; place-items: center; color: var(--soft); font-family: var(--mono); font-size: 11px; pointer-events: none; }
.waveform-wrap.has-waveform .waveform-empty { display: none; }
.marker-rail {
  position: absolute;
  inset: auto 0 0;
  height: 32px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.56);
}
.time-marker {
  position: absolute;
  top: 8px;
  width: 14px;
  height: 17px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translateX(0);
}
.time-marker::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 1.5px;
  height: 13px;
  border-radius: 2px;
  background: var(--accent);
}
.time-marker::after {
  content: "";
  position: absolute;
  left: 2.5px;
  top: 1px;
  width: 8px;
  height: 6px;
  border-radius: 1px 2px 2px 1px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%);
}
.time-marker:hover, .time-marker:focus-visible { transform: translateY(-1px); outline: none; }
.time-marker.is-active::before, .time-marker.is-active::after { background: var(--ink); }
.transport { margin-top: 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.transport-time { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.transport-end { text-align: right; }
.transport-buttons { display: flex; align-items: center; gap: 11px; }
.icon-button, .play-button {
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.icon-button { min-width: 44px; height: 40px; border-radius: 12px; color: var(--muted); background: white; }
.play-button { min-width: 76px; height: 46px; border-radius: 999px; color: white; background: var(--ink); }
.play-button.is-playing { background: var(--accent); }

.stamp-console {
  margin-top: 14px;
  min-height: 76px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(224, 87, 79, .24);
  border-radius: 16px;
  background: var(--accent-soft);
}
.active-line-block { min-width: 0; flex: 1; }
.active-line-block strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-size: 16px; letter-spacing: -.02em; }
.stamp-actions { display: grid; grid-template-columns: 78px minmax(170px, 210px); gap: 8px; }
.stamp-actions .button.compact { min-height: 40px; padding-inline: 13px; border-radius: 11px; }
.stamp-actions .button.stamp { min-height: 42px; padding-inline: 15px; border-radius: 11px; }
.stamp-actions .button.stamp kbd { min-width: 20px; height: 20px; margin-left: 9px; border-radius: 5px; }
.lyrics-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.offset-group { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 750; }
.offset-group button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; cursor: pointer; font-size: 11px; }
.lyrics-list { height: 430px; overflow: auto; scroll-behavior: smooth; }
.empty-state { height: 100%; display: grid; place-content: center; text-align: center; color: var(--soft); }
.empty-state span { font-family: var(--mono); font-size: 28px; }
.empty-state p { margin: 11px 0 0; font-size: 13px; }
.lyric-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  transition: background .16s ease;
}
.lyric-row.is-active { background: rgba(224, 87, 79, .075); }
.lyric-row.is-previewing { background: rgba(224, 87, 79, .13); }
.time-input {
  width: 88px;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--accent-dark);
  background: #fff;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}
.time-input:focus { border-color: var(--accent); }
.lyric-text {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
}
.row-actions { display: flex; gap: 5px; }
.row-actions button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: white;
  cursor: pointer;
  font-size: 12px;
}
.export-bar { margin-top: 18px; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); }
.export-copy strong, .export-copy span { display: block; }
.export-copy strong { font-size: 14px; }
.export-copy span { margin-top: 4px; color: var(--soft); font-size: 11px; }
.export-actions { display: flex; gap: 9px; }

.privacy-section { padding: 104px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 80px; border-bottom: 1px solid var(--line); }
.privacy-section h2 { max-width: 550px; margin: 18px 0 0; font-family: var(--display); font-size: clamp(38px, 5vw, 62px); line-height: 1.06; letter-spacing: -.05em; }
.privacy-section > p { max-width: 580px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.75; }
footer { width: var(--page); min-height: 112px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--soft); font-size: 12px; }
.footer-brand img { width: 30px; height: 30px; border-radius: 8px; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  max-width: min(440px, calc(100vw - 28px));
  padding: 13px 18px;
  border-radius: 12px;
  color: white;
  background: var(--ink);
  box-shadow: 0 18px 50px rgba(0,0,0,.2);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .editor-shell { grid-template-columns: 320px minmax(0, 1fr); }
  .setup-panel { padding: 28px 24px; }
  .timing-panel { padding: 28px; }
}

@media (max-width: 820px) {
  :root { --page: calc(100vw - 28px); }
  .local-badge, .nav-link { display: none; }
  .intro { padding: 62px 0 42px; }
  .editor-shell { display: block; border-radius: 22px; }
  .setup-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  textarea { min-height: 190px; }
  .privacy-section { padding: 76px 0; grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 560px) {
  .site-header .nav { height: 64px; }
  .brand span { font-size: 14px; }
  .app-link { min-height: 40px; padding: 0 13px; }
  h1 { font-size: 52px; }
  .intro > p:last-child { font-size: 17px; }
  .setup-panel, .timing-panel { padding: 22px 18px; }
  .setup-actions { grid-template-columns: 1fr; }
  .workspace-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .player-stage { padding: 18px 14px; }
  .track-meta { align-items: flex-start; }
  .waveform-wrap { height: 180px; }
  #timeline-ruler { height: 40px; }
  #waveform { height: 110px; }
  .waveform-empty { inset: 40px 0 30px; }
  .marker-rail { height: 30px; }
  .stamp-console { align-items: stretch; flex-direction: column; gap: 11px; padding: 13px; }
  .stamp-actions { grid-template-columns: 1fr; }
  .button.stamp { order: -1; }
  .lyrics-toolbar { align-items: flex-start; flex-direction: column; padding: 12px 0; }
  .lyric-row { grid-template-columns: 76px minmax(0, 1fr); gap: 8px; }
  .time-input { width: 76px; }
  .row-actions { grid-column: 2; justify-content: flex-end; }
  .export-bar { align-items: stretch; flex-direction: column; }
  .export-actions { display: grid; grid-template-columns: 1fr 1fr; }
  footer { padding: 30px 0; align-items: flex-start; flex-direction: column; }
}

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