:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #63717b;
  --line: #d8e0e5;
  --paper: #f6f8f9;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --amber: #a16207;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 16px 36px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.topbar p,
.output-panel h2,
.history-section h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.09);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.badge.muted {
  border-color: var(--line);
  background: #f7fafb;
  color: var(--muted);
}

.badge.busy {
  border-color: rgba(161, 98, 7, 0.25);
  background: rgba(161, 98, 7, 0.1);
  color: var(--amber);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 560px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.control-panel,
.output-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 16px;
  overflow: auto;
}

.output-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 16px;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #edf3f4;
}

.mode-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}

.mode-button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(23, 32, 38, 0.08);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.band-title {
  color: #31424d;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.field b {
  color: var(--accent);
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  border-radius: 6px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.tag-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag-button {
  min-height: 32px;
  border: 1px solid #bed0d8;
  background: #f7fafb;
  color: #31424d;
  border-radius: 999px;
  cursor: pointer;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag-button:hover {
  border-color: rgba(15, 118, 110, 0.42);
  color: var(--accent);
}

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

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.grid {
  display: grid;
  gap: 10px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

.settings-band {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.band-title {
  margin-bottom: 10px;
  text-transform: uppercase;
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 100%;
  border: 1px dashed #9fb2bd;
  background: #f7fafb;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
  padding: 10px;
}

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

.clone-source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 10px;
  margin-bottom: 10px;
}

.record-box {
  min-width: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 6px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

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

.record-actions .secondary-action {
  min-height: 36px;
  font-size: 13px;
}

.record-actions .secondary-action.recording {
  border-color: rgba(180, 35, 24, 0.4);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.record-actions .secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.record-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

#recordPreview {
  height: 34px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 12px 0;
  color: #31424d;
  font-size: 13px;
}

.toggles label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.toggles input {
  accent-color: var(--accent);
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.download,
.icon-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
}

.primary-action {
  background: var(--accent);
  color: var(--accent-ink);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-action,
.download,
.icon-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.download {
  min-width: 92px;
  padding: 0 12px;
}

.download.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.now-playing {
  display: grid;
  gap: 12px;
}

.result-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-head h2,
.history-section h2 {
  font-size: 18px;
  line-height: 1.25;
}

.result-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#waveform {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  background: #0f1720;
  display: block;
}

audio {
  width: 100%;
}

.error-box {
  margin: 0;
  white-space: pre-wrap;
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
}

.history-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.history-list {
  min-height: 160px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 6px;
  background: #ffffff;
}

.history-item strong {
  font-size: 13px;
}

.history-item small {
  color: var(--muted);
}

.history-item audio {
  height: 34px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    padding: 10px;
  }

  .grid.two,
  .grid.three,
  .clone-source-grid {
    grid-template-columns: 1fr;
  }

  .action-row {
    grid-template-columns: 1fr;
  }
}
