:root {
  color-scheme: light;
  --page-background: #f3f5f7;
  --panel-background: #ffffff;
  --panel-subtle: #f8fafb;
  --line: #d8dee5;
  --line-strong: #c2cbd5;
  --text: #17202a;
  --muted: #5f6b78;
  --muted-strong: #45515e;
  --focus: #246bfe;
  --danger: #aa2634;
  --shadow: 0 12px 30px rgba(27, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-background);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(85, 124, 173, 0.09), transparent 34rem),
    var(--page-background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button,
audio {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
.spectrogram:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 64%);
  outline-offset: 2px;
}

.report-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 36px 32px 48px;
}

.report-header {
  margin-bottom: 26px;
}

.report-name {
  min-height: 1.2em;
  margin: 0 0 7px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.report-name:empty {
  display: none;
}

.report-title {
  max-width: 1050px;
  margin: 0;
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.04;
}

.report-content {
  display: grid;
  gap: 20px;
}

.report-message {
  margin: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-background);
  color: var(--muted-strong);
  box-shadow: var(--shadow);
}

.report-message--error {
  border-color: #e5b8be;
  background: #fff7f8;
  color: var(--danger);
}

.report-case {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-background);
  box-shadow: var(--shadow);
}

.case-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 61px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-subtle);
}

.case-heading-wrap {
  min-width: 0;
}

.case-title {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 20px;
  font-weight: 740;
  letter-spacing: -0.016em;
  line-height: 1.25;
}

.case-id {
  overflow-wrap: anywhere;
  margin: 3px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.audio-rows {
  display: grid;
  gap: 0;
}

.audio-row {
  padding: 17px 18px 19px;
}

.audio-row + .audio-row {
  border-top: 1px solid var(--line);
}

.row-label {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0.012em;
}

.audio-grid {
  display: grid;
  grid-template-columns: repeat(var(--column-count), minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding: 1px 1px 5px;
  scrollbar-color: var(--line-strong) transparent;
}

.audio-card {
  min-width: 190px;
  padding: 11px;
  border: 1px solid var(--card-border, #c6ced7);
  border-top: 6px solid var(--card-accent, #657384);
  border-radius: 10px;
  background: var(--card-background, #f5f7f9);
}

.audio-label {
  display: block;
  min-height: 34px;
  margin: 0 2px 5px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
}

.metric-value {
  margin: 0 2px 9px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.audio-card audio {
  display: block;
  width: 100%;
  height: 36px;
}

.spectrogram-wrap {
  min-height: 62px;
  margin-top: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #090a0c;
}

.spectrogram {
  display: block;
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 5px;
  background: #090a0c;
  cursor: zoom-in;
}

.spectrogram-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 8px;
  color: #d3d8df;
  font-size: 12px;
  text-align: center;
}

.case-remove {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid #dfadb4;
  border-radius: 8px;
  background: #fff8f9;
  color: var(--danger);
  font-size: 13px;
  font-weight: 730;
  cursor: pointer;
}

.case-remove:hover {
  background: #ffedef;
}

.case-remove:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.spectrogram-modal[hidden] {
  display: none;
}

.spectrogram-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 5vh 4vw;
  background: rgba(9, 12, 16, 0.92);
}

.spectrogram-modal-image {
  display: block;
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 7px;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.55);
  transform-origin: center;
  transition: transform 120ms ease-out;
  touch-action: none;
  user-select: none;
}

.spectrogram-modal-image.is-zoomed {
  cursor: grab;
}

.spectrogram-modal-image.is-dragging {
  cursor: grabbing;
  transition: none;
}

.spectrogram-controls {
  position: absolute;
  z-index: 1;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  gap: 7px;
}

.spectrogram-control {
  min-width: 40px;
  padding: 8px 12px;
  border: 1px solid #cdd3db;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 740;
  cursor: pointer;
}

.spectrogram-control:hover {
  background: #edf1f5;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .report-shell {
    padding: 24px 15px 34px;
  }

  .report-header {
    margin-bottom: 19px;
  }

  .case-header,
  .audio-row {
    padding-right: 13px;
    padding-left: 13px;
  }

  .case-title {
    font-size: 17px;
  }

  .case-remove {
    padding: 7px 9px;
  }

  .spectrogram-controls {
    top: 10px;
    right: 10px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .report-shell {
    width: 100%;
    padding: 0;
  }

  .report-case {
    break-inside: avoid;
    box-shadow: none;
  }

  .audio-grid {
    overflow: visible;
  }
}
