/* SPDX-License-Identifier: AGPL-3.0-or-later */
:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08090c;
  color: #f4f6fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100dvh;
  background: #08090c;
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-height: 100dvh;
  padding: 14px;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: #a8b0c2;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fileButton,
button {
  min-height: 36px;
  border: 1px solid #3b4356;
  border-radius: 6px;
  padding: 7px 12px;
  color: #f4f6fb;
  background: #171b25;
  cursor: pointer;
}

.fileButton:hover,
button:hover:not(:disabled) {
  background: #202638;
}

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

.fileButton input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.workspace {
  position: relative;
  min-height: clamp(320px, 58dvh, 520px);
  border: 1px solid #202638;
  border-radius: 8px;
  overflow: hidden;
  background: #020306;
}

.workspace:not(.hasFile) {
  cursor: pointer;
}

.workspace.hasFile {
  cursor: crosshair;
}

.workspace.dragging {
  border-color: #8fb8ff;
}

.workspace:focus-visible {
  outline: 2px solid #8fb8ff;
  outline-offset: 2px;
}

#spectrogramCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: clamp(320px, 58dvh, 520px);
}

.emptyState {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: #abb4c8;
  pointer-events: none;
}

.emptyState strong {
  color: #f4f6fb;
  font-size: 18px;
}

.emptyState span {
  max-width: 520px;
  font-size: 13px;
  line-height: 1.4;
}

.emptyState.hidden {
  display: none;
}

.controls {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid #202638;
  border-radius: 8px;
  background: #10131b;
}

.controls label,
.controlField {
  position: relative;
  display: grid;
  gap: 6px;
  color: #aeb7ca;
  font-size: 12px;
  text-transform: uppercase;
}

.controlLabel {
  display: inline;
}

.labelRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.helpButton {
  display: inline-grid;
  place-items: center;
  width: 20px;
  min-height: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0;
  color: #aeb7ca;
  font-size: 12px;
  line-height: 1;
}

.helpIcon {
  font-weight: 700;
  font-family: ui-serif, Georgia, serif;
  font-style: italic;
}

.helpText {
  display: none;
}

.helpButton:hover,
.helpButton:focus-visible {
  color: #f4f6fb;
}

.tooltip {
  position: absolute;
  z-index: 5;
  top: 22px;
  right: 0;
  pointer-events: none;
  display: none;
  width: min(280px, 80vw);
  border: 1px solid #3b4356;
  border-radius: 6px;
  padding: 10px;
  color: #d8deeb;
  background: #080b12;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.35);
  font-size: 12px;
  line-height: 1.45;
  text-transform: none;
}

.tooltip.open {
  display: block;
}

.controls select,
.controls input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #323a4d;
  border-radius: 6px;
  padding: 6px 8px;
  color: #f4f6fb;
  background: #080b12;
  text-transform: none;
}

.progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #262c3a;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: #7aa2ff;
  transition: width 120ms ease;
}

.status {
  min-height: 36px;
  margin: 0;
  color: #a8b0c2;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  line-height: 1.35;
}

.statusToast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  display: none;
  max-width: 520px;
  margin: 0 auto;
  border: 1px solid #4b556d;
  border-radius: 8px;
  padding: 11px 13px;
  color: #f4f6fb;
  background: #151a25;
  box-shadow: 0 16px 42px rgb(0 0 0 / 0.42);
  font-size: 13px;
  line-height: 1.35;
}

.statusToast.open {
  display: block;
}

.controlFooter {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid #202638;
}

.repoLink {
  color: #7f889a;
  font-size: 12px;
  text-decoration: none;
}

.repoLink:hover {
  color: #f4f6fb;
  text-decoration: underline;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

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

  .actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .actions .fileButton,
  .actions button {
    flex: 1;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .app {
    gap: 10px;
    padding: 10px;
  }

  .topbar {
    gap: 10px;
    min-height: 0;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand p,
  .status {
    font-size: 12px;
  }

  .statusToast {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .workspace,
  #spectrogramCanvas {
    min-height: 300px;
  }

  .controls {
    gap: 10px;
    padding: 12px;
  }

  .controls label,
  .controlField {
    gap: 5px;
  }

  .helpButton {
    display: inline-flex;
    width: auto;
    min-height: 28px;
    height: 28px;
    gap: 5px;
    padding: 0 8px;
    font-size: 12px;
  }

  .helpText {
    display: inline;
    font-family: inherit;
    font-style: normal;
    font-weight: 600;
  }
}

@media (max-width: 420px) {
  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions .fileButton,
  .actions button {
    width: 100%;
  }

  .workspace,
  #spectrogramCanvas {
    min-height: 260px;
  }
}
