:root {
  --bg: #12151a;
  --bg-elev: #1a1f27;
  --bg-panel: #171c24;
  --line: #2a3340;
  --text: #e8edf5;
  --muted: #8b97a8;
  --accent: #e8a838;
  --accent-2: #3ecfbe;
  --danger: #e85d5d;
  --ok: #5dcb8a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font-display: "Syne", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 168, 56, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(62, 207, 190, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top,
.layout,
.foot {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding: 1.75rem 2rem 1rem;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
}

.brand h1 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.top-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.ghost-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
  font-size: 0.8rem;
}

.ghost-link:hover {
  color: var(--accent-2);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem 2rem 2rem;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%),
    var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.control .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

select,
input {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.65rem 0.7rem;
  font: inherit;
}

select:focus,
input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.muted {
  margin: -0.4rem 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

button {
  font: inherit;
  border-radius: 3px;
  border: 1px solid transparent;
  padding: 0.7rem 1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  color: #1a1205;
  font-weight: 600;
}

.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

.corpus {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.corpus-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.corpus-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.muted-inline {
  color: var(--muted);
  font-size: 0.72rem;
}

.file-field input[type="file"] {
  padding: 0.45rem;
  font-size: 0.75rem;
}

.corpus code {
  color: var(--accent-2);
}

.corpus-list {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #0d1015;
}

.corpus-list:empty::after {
  content: "No corpus files yet";
  display: block;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.corpus-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
}

.corpus-item:last-child {
  border-bottom: none;
}

.corpus-item-meta {
  min-width: 0;
  flex: 1;
}

.corpus-item-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.corpus-item-size {
  color: var(--muted);
  font-size: 0.68rem;
}

.corpus-item .ghost {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding: 0.25rem 0.45rem;
  font-size: 0.7rem;
}

.corpus-item .ghost:hover {
  border-color: var(--danger);
}

.live-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.live-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill.idle {
  color: var(--muted);
}

.pill.running {
  color: var(--accent-2);
  border-color: rgba(62, 207, 190, 0.45);
}

.pill.completed {
  color: var(--ok);
  border-color: rgba(93, 203, 138, 0.45);
}

.pill.aborted,
.pill.failed {
  color: var(--danger);
  border-color: rgba(232, 93, 93, 0.45);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.stats strong {
  font-size: 1.1rem;
}

.bar-track {
  height: 8px;
  background: #0d1015;
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
}

.log-wrap h3 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}

.log {
  margin: 0;
  height: min(46vh, 420px);
  overflow: auto;
  background: #0d1015;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 2rem 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.foot code {
  color: var(--accent-2);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .top {
    padding: 1.25rem 1rem 0.75rem;
    flex-direction: column;
    align-items: start;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }
}
