:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1c2429;
  --muted: #64727c;
  --line: #d8e0e4;
  --accent: #0f7b78;
  --accent-strong: #095e5c;
  --gold: #bc8b2c;
  --danger: #aa3d3d;
  --shadow: 0 18px 45px rgba(23, 34, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.app-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.96fr) minmax(390px, 1.08fr) minmax(320px, 0.96fr);
  gap: 28px;
  align-items: stretch;
}

.stage-column {
  position: relative;
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
  min-height: 820px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 34, 40, 0.06);
}

.stage-column:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 45%;
  right: -29px;
  width: 29px;
  height: 68px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  filter: drop-shadow(0 8px 12px rgba(15, 123, 120, 0.18));
  z-index: 2;
}

.stage-input {
  background: linear-gradient(180deg, #f4faf5 0%, #f8fbf7 100%);
}

.stage-setting {
  background: linear-gradient(180deg, #f1fbfc 0%, #f7fbfb 100%);
}

.stage-process {
  background: linear-gradient(180deg, #f5f6ff 0%, #fafaff 100%);
}

.stage-title {
  color: var(--accent);
  font-size: 28px;
  line-height: 1.05;
}

.stage-process .stage-title {
  color: #45429d;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(23, 34, 40, 0.08);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-heading button {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.input-panel,
.preset-panel,
.controls-panel {
  min-height: 0;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 16px;
  border: 1px dashed #aebbc2;
  border-radius: 8px;
  background: #f9fbfb;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: #edf8f7;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  color: var(--ink);
  font-size: 16px;
}

.drop-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 300;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.meta-grid div,
.meter-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

dt,
.meter-grid span {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

dd,
.meter-grid strong {
  display: block;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 800;
}

.true-peak-cell > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.true-peak-cell.has-caution {
  border-color: #d6a14a;
  background: #fffaf0;
}

.caution-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #d98d00;
  color: #111817;
  clip-path: polygon(50% 4%, 96% 92%, 4% 92%);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.caution-icon:hover:not(:disabled) {
  border-color: transparent;
  background: #f2a600;
}

.caution-icon:active:not(:disabled) {
  transform: none;
}

.caution-icon[hidden] {
  display: none;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stage-setting .preset-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preset-card {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.preset-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.preset-card strong {
  font-size: 15px;
}

.preset-card span {
  color: var(--muted);
  font-size: 12px;
}

.control-grid,
.select-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  min-width: 0;
}

label > span {
  display: flex;
  align-items: center;
  min-height: 20px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

output {
  display: block;
  min-height: 20px;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.benchmark-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.benchmark-box strong {
  display: block;
  font-size: 13px;
}

.benchmark-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-weight: 700;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 44px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: #cbd5da;
  transition: background 140ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.export-panel,
.meters-panel,
.compare-panel {
  grid-column: span 1;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.action-row .primary {
  min-height: 58px;
  font-size: 17px;
}

button.process-primary,
button.export-primary {
  min-height: 120px;
  border: 2px solid #d97d00;
  background: #ffc928;
  color: #111817;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 8px 0 #d87900, 0 16px 28px rgba(198, 126, 0, 0.18);
}

button.process-primary:hover:not(:disabled),
button.export-primary:hover:not(:disabled) {
  border-color: #c86f00;
  background: #ffd84b;
}

button.process-primary:active:not(:disabled),
button.export-primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 5px 0 #d87900, 0 10px 20px rgba(198, 126, 0, 0.16);
}

.export-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

button.export-primary {
  width: 100%;
}

.progress-shell {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef1;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.meter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stage-input .meter-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.process-panel .select-row {
  margin-bottom: 18px;
}

.compare-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.compare-tabs button.active {
  border-color: var(--gold);
  background: #fff8e8;
  font-weight: 800;
}

audio {
  width: 100%;
  min-height: 44px;
}

.modal {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(23, 34, 40, 0.25);
}

.modal::backdrop {
  background: rgba(17, 24, 28, 0.38);
}

.modal form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  font-size: 18px;
}

.modal p {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.75;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.modal-actions .primary {
  min-width: 96px;
}

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

  .stage-column {
    min-height: 0;
  }

  .stage-column::after {
    display: none;
  }
}

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

  .topbar,
  .workspace,
  .control-grid,
  .benchmark-box,
  .select-row,
  .meta-grid,
  .meter-grid,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .stage-setting .preset-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }
}
