:root {
  --bg:      #0f1117;
  --surface: #1a1d27;
  --border:  #2a2d3a;
  --text:    #e2e8f0;
  --muted:   #8892a4;
  --accent:  #4f8ef7;
  --flair:   #7c3aed;
  --ich:     #dc2626;
  --ctp:     #059669;
  --done:    #16a34a;
  --failed:  #dc2626;
  --queued:  #ca8a04;
  --processing: #2563eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

nav a { color: var(--muted); text-decoration: none; font-size: .9rem; }
nav a:hover, nav a.active { color: var(--text); }
nav .nav-brand { font-weight: 700; font-size: 1rem; color: var(--accent); }
nav .nav-spacer { flex: 1; }

main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

h1 { font-size: 1.6rem; margin-bottom: 1.25rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; color: var(--text); }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; color: var(--muted); }

.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }

/* Module cards */
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.module-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.module-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.module-card p  { color: var(--muted); font-size: .9rem; }
.module-card.flair h2 { color: var(--flair); }
.module-card.ich   h2 { color: var(--ich);   }
.module-card.ctp   h2 { color: var(--ctp);   }

/* Badges */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 600; text-transform: uppercase; }
.badge.flair { background: #3b1f6e; color: #c4b5fd; }
.badge.ich   { background: #7f1d1d; color: #fca5a5; }
.badge.ctp   { background: #064e3b; color: #6ee7b7; }

/* Status */
.status { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .8rem; font-weight: 600; }
.status.done       { background: #14532d; color: #86efac; }
.status.failed     { background: #7f1d1d; color: #fca5a5; }
.status.queued     { background: #713f12; color: #fde68a; }
.status.processing,
.status.downloading,
.status.converting,
.status.registering,
.status.segmenting,
.status.uploading { background: #1e3a8a; color: #93c5fd; }
.status.new        { background: var(--border); color: var(--muted); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); border-radius: 8px; overflow: hidden; }
thead { background: var(--border); }
th, td { padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
th.sortable:hover { color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.03); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Forms */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
input[type="text"], input[type="search"] {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: .5rem .75rem; border-radius: 6px; width: 100%; font-size: .95rem;
}
input:focus { outline: none; border-color: var(--accent); }
.btn, button[type="submit"] {
  background: var(--accent); color: #fff; border: none; padding: .55rem 1.25rem;
  border-radius: 6px; cursor: pointer; font-size: .9rem; font-weight: 600; text-decoration: none;
  display: inline-block;
}
.btn:hover, button[type="submit"]:hover { background: #3b7de8; text-decoration: none; }

.btn-small { background: var(--accent); color: #fff; border: none; padding: .3rem .8rem; border-radius: 5px; cursor: pointer; font-size: .8rem; font-weight: 600; }
.btn-small:hover { background: #3b7de8; }
.muted { color: var(--muted); }
.search-form { display: flex; gap: .75rem; margin-bottom: 1.5rem; }
.search-form input { max-width: 400px; }

/* Two column layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }

/* Meta */
dl.meta { display: grid; grid-template-columns: 160px 1fr; gap: .4rem 1rem; font-size: .9rem; margin-bottom: 1.5rem; }
dt { color: var(--muted); }
dd code { font-size: .8rem; background: var(--border); padding: .1rem .35rem; border-radius: 3px; }

/* Result highlight */
.result-highlight { margin: 1rem 0; }
.big-number { font-size: 3rem; font-weight: 700; color: var(--accent); }
.unit { font-size: 1.5rem; color: var(--muted); margin-left: .25rem; }

/* Viewer links */
.viewer-links { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-top: .75rem; }
.viewer-links .hint { color: var(--muted); font-size: .85rem; margin-top: .5rem; }

/* Messages */
.processing { color: #93c5fd; padding: .75rem; background: #1e3a8a22; border-radius: 6px; margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .85rem; }
.error { color: #fca5a5; }
.empty { color: var(--muted); }
.error-log { background: #1c0a0a; border: 1px solid #7f1d1d; border-radius: 6px; padding: 1rem; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; color: #fca5a5; }

details summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: 1rem; }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; }

/* Fazekas scores */
.fazekas-scores { margin: .75rem 0 1rem; }
.fazekas-grade { font-size: 1.6rem; font-weight: 700; text-align: center; width: 4rem; }
.fazekas-grade.grade-0 { color: #86efac; }   /* green  — none */
.fazekas-grade.grade-1 { color: #fde68a; }   /* yellow — mild */
.fazekas-grade.grade-2 { color: #fb923c; }   /* orange — moderate */
.fazekas-grade.grade-3 { color: #f87171; }   /* red    — severe */
.fazekas-features td:last-child { font-family: monospace; }
