:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #1d2525;
  --muted: #64706d;
  --line: #d9dfdc;
  --accent: #0b6f6a;
  --accent-strong: #064f4c;
  --confirm: #147a42;
  --reject: #b93d35;
  --uncertain: #f2c230;
  --uncertain-ink: #5a4100;
  --warn: #a66610;
  --shadow: 0 10px 30px rgba(29, 37, 37, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
  touch-action: manipulation;
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 14px;
}

.topbar,
.controls,
.spectrogram-panel,
.review-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.topbar-copy {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.topbar-icon-button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8efee;
  color: var(--ink);
}

.material-icon {
  width: 24px;
  height: 24px;
  display: block;
  fill: currentColor;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.1rem, 2.2vw, 1.55rem);
}

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

.controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.metric-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.spectrogram-panel {
  grid-column: 1 / -1;
  padding: 10px;
}

.spectrogram-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3.4 / 1;
  min-height: 118px;
  max-height: 260px;
  overflow: hidden;
  border-radius: 6px;
  background: #111;
}

.spectrogram-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

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

.spectrogram-band {
  position: absolute;
  top: 0;
  bottom: 0;
  display: none;
  z-index: 3;
  background: rgba(255, 255, 255, 0.07);
  overflow: visible;
  pointer-events: none;
}

.spectrogram-band::before,
.spectrogram-band::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.98) 0,
    rgba(255, 255, 255, 0.98) 8px,
    transparent 8px,
    transparent 14px
  );
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.95))
    drop-shadow(0 0 3px rgba(0, 0, 0, 0.95));
}

.spectrogram-band::before {
  left: -2px;
}

.spectrogram-band::after {
  right: -2px;
}

.play-region-line {
  position: absolute;
  top: 4px;
  bottom: 4px;
  display: none;
  z-index: 4;
  width: 5px;
  border-radius: 3px;
  background: #f7d13a;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 8px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.play-region-start {
  left: 5px;
}

.play-region-end {
  right: 5px;
}

.spectrogram-playhead {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  display: none;
  z-index: 5;
  width: 3px;
  border-radius: 2px;
  background: #36d7ff;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.92),
    0 0 10px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  transform: translateX(-50%);
}

.spectrogram-panel p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.review-card {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}

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

.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.pill {
  background: #e8efee;
  color: var(--accent-strong);
}

.status-pill.unreviewed {
  background: #f2ede3;
  color: var(--warn);
}

.status-pill.confirmed {
  background: #e2f3e9;
  color: var(--confirm);
}

.status-pill.rejected {
  background: #fae6e4;
  color: var(--reject);
}

.status-pill.uncertain {
  background: #f8ead2;
  color: var(--uncertain-ink);
}

audio {
  width: 100%;
}

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

.decision-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.decision-row button {
  min-width: 0;
  padding: 0 8px;
  font-size: 0.82rem;
}

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

.primary:active {
  background: var(--accent-strong);
}

.secondary,
.icon-button {
  background: #e8efee;
  color: var(--ink);
}

.confirm {
  background: var(--confirm);
  color: white;
}

.reject {
  background: var(--reject);
  color: white;
}

.uncertain {
  background: var(--uncertain);
  color: var(--ink);
}

.danger-quiet {
  background: #f5e6e4;
  color: var(--reject);
}

.call-meta {
  display: flex;
  gap: 8px;
}

.metric-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background: rgba(29, 37, 37, 0.48);
}

.help-modal {
  width: min(520px, 100%);
  max-height: min(640px, 86svh);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(29, 37, 37, 0.28);
}

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

.help-head h2 {
  font-size: 1.1rem;
}

.help-list {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--ink);
}

.help-list li {
  margin: 10px 0;
  line-height: 1.38;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

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

  .review-card {
    position: sticky;
    top: 82px;
    z-index: 4;
  }

  .metric-title {
    font-size: 0.66rem;
  }

  .metric-card {
    padding: 8px;
  }

  .metric-card strong {
    font-size: 1rem;
  }
}

@media (max-width: 390px) {
  button {
    padding: 0 10px;
  }

  .play-row,
  .decision-row {
    gap: 8px;
  }

  .decision-row button {
    padding: 0 6px;
    font-size: 0.78rem;
  }
}
