/* ── reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --border:    #222222;
  --accent:    #c8f542;
  --accent2:   #f5a623;
  --muted:     #555555;
  --text:      #e8e8e8;
  --text-dim:  #888888;
  --radius:    4px;
  --font-mono: 'Space Mono', monospace;
  --font-serif:'DM Serif Display', serif;
}

/* ── base ──────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* grain overlay */
.grain {
  pointer-events: none;
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.04;
  z-index: 999;
  animation: grain 0.5s steps(1) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  10%      { transform: translate(-2%,-3%); }
  20%      { transform: translate(3%,2%); }
  30%      { transform: translate(-1%,4%); }
  40%      { transform: translate(4%,-1%); }
  50%      { transform: translate(-3%,3%); }
  60%      { transform: translate(2%,-4%); }
  70%      { transform: translate(-4%,1%); }
  80%      { transform: translate(1%,-2%); }
  90%      { transform: translate(-2%,4%); }
}

/* ── header ────────────────────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo-mark {
  font-family: var(--font-serif);
  font-size: 42px;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -2px;
}
.header-text h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
}
.header-text .subtitle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}
/* ── main ──────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 32px;
}

/* ── upload / drop zone ────────────────────────────────────────────────────── */
.upload-section { width: 100%; }

.drop-zone {
  border: 1px dashed var(--border);
  background: var(--surface);
  padding: 64px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: #141414;
}
.drop-zone.drag-over { background: #131a00; }

.waveform-icon {
  color: var(--accent);
  width: 80px;
  margin: 0 auto 24px;
  opacity: 0.8;
  animation: pulse-bars 1.4s ease-in-out infinite alternate;
}
@keyframes pulse-bars {
  from { opacity: 0.5; transform: scaleY(0.95); }
  to   { opacity: 1;   transform: scaleY(1.05); }
}

.drop-label {
  font-family: var(--font-serif);
  font-size: 26px;
  color: var(--text);
  margin-bottom: 8px;
}
.drop-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 28px;
  letter-spacing: 0.05em;
}
.browse-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 10px 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 0.15s;
}
.browse-btn:hover { opacity: 0.85; }

/* ── spinner ───────────────────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 80px 0;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── results ───────────────────────────────────────────────────────────────── */
.results-section { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

.results-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.results-header h2 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
}
.filename {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* verdict */
.verdict-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.verdict-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-width: 140px;
}
.verdict-value {
  font-family: var(--font-serif);
  font-size: 48px;
  line-height: 1;
  letter-spacing: -1px;
}
.verdict-beeping  { color: var(--accent); }
.verdict-ringing  { color: var(--accent2); }
.verdict-speech   { color: #7eb8f7; }
.verdict-silence  { color: var(--muted); }
.verdict-unknown  { color: #c44; }

/* stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}
.stat-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--accent);
  line-height: 1;
}
.stat-unit {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.06em;
}

/* aggregated */
.agg-section h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 14px;
  color: var(--text-dim);
}
.agg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px 20px;
  margin-bottom: 10px;
}
.agg-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 10px;
}
.agg-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 0;
}
.agg-row span:last-child { color: var(--text); }
.conf-bar-wrap {
  background: var(--border);
  height: 3px;
  margin-top: 10px;
  border-radius: 2px;
  overflow: hidden;
}
.conf-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* reset */
.reset-btn {
  margin-top: 28px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.reset-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

/* ── per-frame table ───────────────────────────────────────────────────────── */
.frames-section {
  margin-top: 28px;
}
.frames-section h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 14px;
  color: var(--text-dim);
}
.frames-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.frames-table thead tr {
  background: #161616;
  border-bottom: 1px solid var(--border);
}
.frames-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}
.frames-table tbody tr {
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.1s;
}
.frames-table tbody tr:hover {
  background: #141414;
}
.frames-table td {
  padding: 9px 14px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.frames-table td:first-child {
  color: var(--muted);
  width: 60px;
}
.frames-table td:nth-child(2) {
  color: var(--text);
}
.frame-class {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  border-radius: 2px;
}
.frame-class-beeping { color: var(--accent);  border: 1px solid var(--accent);  }
.frame-class-ringing { color: var(--accent2); border: 1px solid var(--accent2); }
.frame-class-speech  { color: #7eb8f7;        border: 1px solid #7eb8f7;        }
.frame-class-silence { color: var(--muted);   border: 1px solid var(--border);  }
.frame-class-other   { color: #555;           border: 1px solid #333;           }

/* ── footer ────────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* ── responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .verdict-value { font-size: 36px; }
  .header-inner { flex-wrap: wrap; }
  .dl-btn { margin-left: 0; }
}