:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 1.25rem; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2rem 0 1.5rem;
}
header h1 {
  font-size: 2rem;
  margin: 0 0 .25rem;
  letter-spacing: -0.02em;
}
.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 1rem;
}

main { padding: 2rem 0 4rem; }

h2 {
  font-size: 1.1rem;
  margin: 0 0 .75rem;
  letter-spacing: -0.01em;
}

section { margin-bottom: 2.5rem; }

.class-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .5rem;
}
.class-grid li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: .5rem;
}

textarea {
  width: 100%;
  padding: .75rem .9rem;
  font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  resize: vertical;
  color: var(--text);
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: .4rem 0 .8rem;
  font-size: 13px;
  color: var(--muted);
}
.muted { color: var(--muted); }
.hint { color: var(--muted); margin: 0 0 .75rem; font-size: 14px; }

.controls {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

button, .btn-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1rem;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover:not(:disabled), .btn-file:hover {
  background: #f4f4f5;
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.ghost {
  background: transparent;
}

.turnstile-box {
  margin: 1rem 0;
  min-height: 65px;
}

#status {
  margin: .5rem 0;
  min-height: 1.4em;
  font-size: 14px;
  color: var(--muted);
}
#status.error { color: var(--danger); font-weight: 500; }
#status.success { color: #15803d; }

.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.summary h3 {
  font-size: 14px;
  margin: 0 0 .5rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-bars { display: flex; flex-direction: column; gap: .35rem; }
.summary-bar {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  align-items: center;
  gap: .5rem;
  font-size: 13px;
}
.summary-bar .bar {
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.summary-bar .bar-fill {
  height: 100%;
  border-radius: 99px;
}
.summary-bar .count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
}
th {
  background: #fafafa;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
td.confidence { font-variant-numeric: tabular-nums; color: var(--muted); }

/* Class tags — distinct, accessible colours */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tag-BOOL        { background:#dcfce7; color:#166534; }
.tag-INSTRUCTION { background:#fed7aa; color:#9a3412; }
.tag-SHORT_FACT  { background:#dbeafe; color:#1e40af; }
.tag-DEFINITION  { background:#f3e8ff; color:#6b21a8; }
.tag-COMPARISON  { background:#fecaca; color:#991b1b; }
.tag-REASON      { background:#fef08a; color:#854d0e; }
.tag-CONSEQUENCE { background:#ccfbf1; color:#115e59; }
.tag-OTHER       { background:#e4e4e7; color:#3f3f46; }

/* matching bar-fill colours */
.bar-fill[data-class="BOOL"]        { background:#22c55e; }
.bar-fill[data-class="INSTRUCTION"] { background:#f97316; }
.bar-fill[data-class="SHORT_FACT"]  { background:#3b82f6; }
.bar-fill[data-class="DEFINITION"]  { background:#a855f7; }
.bar-fill[data-class="COMPARISON"]  { background:#ef4444; }
.bar-fill[data-class="REASON"]      { background:#eab308; }
.bar-fill[data-class="CONSEQUENCE"] { background:#14b8a6; }
.bar-fill[data-class="OTHER"]       { background:#71717a; }

footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 600px) {
  header h1 { font-size: 1.6rem; }
  .summary-bar { grid-template-columns: 100px 1fr 50px; }
}
