:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* mouse */
  --series-6: #eb6834;   /* keyboard */
  --status-warning: #fab219;
  --status-warning-ink: #6b4400;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 16px rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-6: #d95926;
    --status-warning: #fab219;
    --status-warning-ink: #2a1c00;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-6: #d95926;
  --status-warning: #fab219;
  --status-warning-ink: #2a1c00;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  position: relative;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 35px 16px 64px;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--series-1), var(--series-6));
}

.app {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-mark {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--series-1), var(--series-6));
  font-size: 18px;
  box-shadow: var(--shadow);
}

header.hero h1 {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

header.hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  max-width: 62ch;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dropzone {
  border: 1.5px dashed var(--baseline);
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 6%, transparent);
}

.dropzone input[type="file"] { display: none; }

.dropzone .dz-icon {
  font-size: 26px;
  margin-bottom: 8px;
  line-height: 1;
}

.dropzone .dz-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dropzone .dz-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.save-opt-in {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.save-opt-in input[type="checkbox"] {
  flex: none;
  margin-top: 2px;
  width: 15px;
  height: 15px;
  accent-color: var(--series-1);
  cursor: pointer;
}

.save-status {
  margin-top: 10px;
  font-size: 12.5px;
}

.save-status.ok { color: var(--text-secondary); }
.save-status.error { color: var(--status-warning-ink); }

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
}

.file-info .name { font-weight: 600; }
.file-info .meta { color: var(--text-muted); }

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--gridline);
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--series-1);
  transition: width 0.15s ease;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  background: color-mix(in srgb, var(--status-warning) 16%, var(--surface-1));
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--status-warning) 40%, transparent);
}

.banner .icon {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--status-warning);
  color: var(--status-warning-ink);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary h2 {
  font-size: 16px;
  margin: 0;
}

.summary-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.table-scroll {
  overflow-x: auto;
}

table.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.summary-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.summary-table td {
  padding: 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.summary-table tbody tr {
  cursor: pointer;
}

.summary-table tbody tr:hover {
  background: color-mix(in srgb, var(--series-1) 6%, transparent);
}

.summary-table tbody tr.selected {
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
}

.summary-table .player-cell {
  font-weight: 600;
}

.summary-table .method-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.summary-table .confidence-note {
  font-size: 11.5px;
  color: var(--text-muted);
}

.summary-footnote {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 2px 0;
}

.back-link {
  display: inline-block;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 2px;
}

.back-link:hover { text-decoration: underline; }

.results-title {
  font-size: 17px;
  margin: 0;
}

.results { display: flex; flex-direction: column; gap: 16px; }

.stats-body { display: flex; flex-direction: column; gap: 22px; }

.verdict-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.badge.keyboard { background: var(--series-6); }
.badge.mouse { background: var(--series-1); }
.badge.inconclusive { background: var(--status-warning); color: var(--status-warning-ink); }
.badge.insufficient-data { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

.confidence-pill {
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.stat-tile {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-tile .label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-tile .value {
  font-size: 20px;
  font-weight: 600;
}

.notes {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-block h3 {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 8px;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 200px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.wkt-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 9px;
  border-radius: 6px;
  transform: translate(0, -100%);
  white-space: nowrap;
  z-index: 5;
}

details.explainer summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

details.explainer[open] summary { margin-bottom: 10px; }

details.explainer .body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
  padding: 8px 0;
}

footer.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding-top: 20px;
  margin-top: 4px;
  border-top: 1px solid var(--gridline);
}

.coffee-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  background: #ff5e5b;
  color: #ffffff;
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.coffee-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

[hidden] { display: none !important; }
