:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e2e5e9;
  --accent: #2563eb;
  --accent-weak: #eaf1ff;
  --good: #16a34a;
  --mid: #d97706;
  --low: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1d2026;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --border: #2b2f36;
    --accent: #6ea8ff;
    --accent-weak: #1c2740;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  word-break: keep-all;
  overflow-wrap: normal;
}

.topbar {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.topbar h1 { margin: 0 0 4px; font-size: 20px; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

main { padding: 20px 32px 60px; max-width: 1200px; margin: 0 auto; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field.grow { flex: 1; min-width: 200px; }
.field label { color: var(--muted); }
.field input {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button:hover { opacity: 0.9; }

.status { min-height: 20px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.summary { font-size: 14px; color: var(--muted); margin-bottom: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

thead { background: var(--accent-weak); }
th, td {
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { white-space: nowrap; }
th.col-score, td.col-score { width: 70px; text-align: center; }
.col-nowrap { white-space: nowrap; }

th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { color: var(--accent); }
th.sortable .sort-arrow { margin-left: 3px; color: var(--accent); }

.title-cell { margin-bottom: 4px; }
.reason-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.reason-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--accent-weak);
  color: var(--accent);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.score-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  color: white;
}
.score-high { background: var(--good); }
.score-mid { background: var(--mid); }
.score-low { background: var(--low); }

tr.detail-row { display: none; background: var(--accent-weak); }
tr.detail-row.open { display: table-row; }
tr.detail-row td { font-size: 12px; }
tr.detail-row ul { margin: 4px 0 12px; padding-left: 18px; }

.g2b-actions {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0 14px;
  max-width: 640px;
}
.g2b-num-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; flex-wrap: wrap; }
.g2b-num-label { color: var(--muted); min-width: 130px; }
.g2b-num-value { font-size: 12px; }
.copy-btn {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.g2b-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 12px;
}

table.detail-table {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
}
table.detail-table th, table.detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  vertical-align: top;
}
table.detail-table th {
  width: 160px;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  background: transparent;
}
table.detail-table tr:last-child th, table.detail-table tr:last-child td { border-bottom: none; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
  white-space: nowrap;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--card);
  border-radius: 10px;
  max-width: 800px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  padding: 20px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.hint { color: var(--muted); font-size: 13px; }
#rawContent h3 { font-size: 13px; margin: 16px 0 6px; color: var(--muted); }
#rawContent h3:first-child { margin-top: 0; }
