:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --ink: #18201d;
  --muted: #66716d;
  --line: #cfd8d4;
  --panel: #ffffff;
  --panel-soft: #eef3f1;
  --teal: #05766c;
  --teal-dark: #045c54;
  --amber: #b65f00;
  --red: #b42318;
  --violet: #5f4bb6;
  --shadow: 0 14px 36px rgba(20, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(90deg, rgba(5, 118, 108, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(180, 35, 24, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body.intro-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(5, 118, 108, 0.12) 1px, transparent 1px),
    linear-gradient(180deg, rgba(180, 35, 24, 0.08) 1px, transparent 1px),
    rgba(244, 246, 245, 0.96);
  background-size: 28px 28px;
}

.intro-overlay[hidden] {
  display: none;
}

.intro-panel {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 80px rgba(20, 31, 28, 0.2);
  padding: clamp(20px, 3.4vw, 34px);
}

.intro-kicker {
  display: block;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.intro-copy h2 {
  margin-top: 8px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.96;
  font-weight: 820;
}

.intro-copy p {
  max-width: 720px;
  margin-top: 14px;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.55;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.intro-grid article,
.intro-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.intro-grid strong,
.intro-note strong {
  display: block;
  color: var(--ink);
  font-size: 0.94rem;
}

.intro-grid p,
.intro-note p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.48;
}

.intro-note {
  margin-top: 12px;
  border-color: rgba(182, 95, 0, 0.34);
  background: rgba(255, 248, 235, 0.78);
}

.intro-start {
  margin-top: 18px;
  min-width: 140px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 1px solid #103f3a;
  border-radius: 8px;
  background:
    radial-gradient(circle at center, transparent 0 10px, #18201d 11px 12px, transparent 13px),
    conic-gradient(from 14deg, #05766c, #38a68f, #f0bd57, #b42318, #5f4bb6, #05766c);
  box-shadow: inset 0 0 0 7px #ffffff, var(--shadow);
}

.brand-mark span {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: #18201d;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.24rem, 1.7vw, 1.72rem);
  line-height: 1.1;
  font-weight: 780;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 760;
}

.brand p,
.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.button {
  padding: 0 14px;
  min-width: 104px;
  font-weight: 700;
}

.button:hover {
  border-color: #9bb1aa;
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.button-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.button-primary.recording {
  background: var(--red);
  border-color: var(--red);
}

.icon-record,
.icon-play,
.icon-download {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.icon-record {
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.34);
}

.button-primary .icon-record {
  background: #ffffff;
}

.button-primary.recording .icon-record {
  border-radius: 3px;
}

.icon-play {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
  transform: translateX(1px);
}

.button.playing .icon-play {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 2px;
  background: currentColor;
  transform: none;
}

.icon-download {
  position: relative;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.icon-download::before {
  content: "";
  position: absolute;
  left: 5px;
  top: -7px;
  width: 2px;
  height: 11px;
  background: currentColor;
}

.icon-download::after {
  content: "";
  position: absolute;
  left: 3px;
  top: -1px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.capture-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.level-wrap {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(5, 118, 108, 0.15), rgba(182, 95, 0, 0.17), rgba(180, 35, 24, 0.2)),
    #e3ebe7;
}

.level-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #e0a42d, var(--red));
  transition: width 70ms linear;
}

.timer {
  min-width: 88px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.readout {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.readout span,
.group-title,
.kv-row span,
.slider-row span,
.toggle-row span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.readout strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2.1vw, 2.15rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.readout small {
  display: block;
  margin-top: 8px;
  min-height: 1.15em;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  align-items: start;
  gap: 16px;
  margin-top: 16px;
}

.waveform-panel,
.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.canvas-tools {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-frame {
  position: relative;
  height: clamp(360px, 52vh, 720px);
  min-height: 360px;
  overflow: hidden;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(24, 32, 29, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 32, 29, 0.045) 1px, transparent 1px),
    #fbfcfb;
  background-size: 32px 32px;
}

#waveCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.overview-frame {
  height: clamp(44px, 6.5vh, 90px);
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(90deg, rgba(24, 32, 29, 0.04) 1px, transparent 1px),
    #f7faf8;
}

#overviewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#overviewCanvas:active {
  cursor: grabbing;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  pointer-events: none;
}

.empty-state[hidden] {
  display: none;
}

.scope-glyph {
  width: 96px;
  height: 56px;
  border: 2px solid #8ca09a;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 10px, rgba(5, 118, 108, 0.18) 10px 12px, transparent 12px 24px),
    linear-gradient(180deg, transparent 50%, rgba(24, 32, 29, 0.2) 50% calc(50% + 1px), transparent calc(50% + 1px));
}

.empty-state strong {
  color: var(--ink);
}

.settings-panel {
  padding: 12px;
}

.settings-group + .settings-group {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.group-title {
  margin-bottom: 9px;
}

.toggle-row,
.slider-row,
.select-row,
.kv-row {
  display: grid;
  align-items: center;
  min-height: 34px;
  gap: 8px;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.slider-row {
  grid-template-columns: 80px minmax(0, 1fr) 66px;
}

.select-row {
  grid-template-columns: 80px minmax(0, 1fr);
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.select-row select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 720;
}

.slider-row output,
.kv-row strong {
  text-align: right;
  color: var(--ink);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.kv-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.compact .kv-row {
  min-height: 29px;
}

@media (max-width: 1060px) {
  .readouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .settings-group + .settings-group {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .capture-strip {
    grid-template-columns: 1fr;
  }

  .timer {
    text-align: left;
  }

  .settings-panel {
    grid-template-columns: 1fr;
  }

  .readouts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .readout {
    padding: 9px 7px;
  }

  .readout span {
    font-size: 0.62rem;
  }

  .readout strong {
    font-size: clamp(0.98rem, 5vw, 1.35rem);
  }

  .readout small {
    font-size: 0.66rem;
  }

  .intro-overlay {
    padding: 12px;
  }

  .intro-panel {
    max-height: calc(100vh - 24px);
  }

  .intro-grid {
    grid-template-columns: 1fr;
  }

  .canvas-frame {
    height: 420px;
    min-height: 420px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .canvas-tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .canvas-tools .button {
    min-width: 0;
  }

  .slider-row {
    grid-template-columns: 74px minmax(0, 1fr) 66px;
  }
}
