:root {
  --bg: #101014;
  --card: #18181f;
  --ink: #e8e6e1;
  --muted: #8f8d86;
  --gold: #c9a45c;
  --gold-dim: #8a7340;
  --line: #2a2a33;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  max-width: 44rem;
  margin: 0 auto;
}

.pi-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.5rem;
  line-height: 1;
  color: var(--gold);
}

h1 {
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 1.9rem;
  margin: 0.4rem 0 1rem;
  letter-spacing: 0.04em;
}

.tagline {
  color: var(--muted);
  font-style: italic;
  margin: 0;
}
.attrib { white-space: nowrap; font-style: normal; }

main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
  max-width: 75rem;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.5rem;
  flex: 0 1 24rem;
}

.card h2 {
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 1.15rem;
  margin: 0 0 1.2rem;
  color: var(--gold);
}

.field { margin-bottom: 1.1rem; }
.field > label, .grid-2 label, .grid-3 label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.radio-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.radio-row label {
  display: flex; align-items: center; gap: 0.35rem;
  cursor: pointer; font-size: 0.95rem;
}
.radio-row input { accent-color: var(--gold); }

input[type=text], input[type=number], select {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font: inherit;
}
input:focus, select:focus { outline: 1px solid var(--gold-dim); }

.pos-row { display: flex; gap: 0.5rem; }
.pos-row input { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.grid-3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0.8rem; }

.hint, .estimate, .corpus {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}
.estimate { margin-bottom: 0.9rem; }
.corpus { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }

button {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--gold-dim); }

button.primary {
  width: 100%;
  background: var(--gold);
  color: #16130c;
  border: none;
  font-weight: 600;
  padding: 0.7rem;
}
button.primary:hover { background: #d8b56e; }
button.primary:disabled { background: var(--gold-dim); cursor: wait; }

.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.8rem;
}
.bar { height: 100%; width: 0; background: var(--gold); transition: width 0.15s; }

.error { color: #d97a6c; font-size: 0.9rem; }

.viewer { flex: 1 1 30rem; text-align: center; }

canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #000;
}

.frame-info {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.controls input[type=range] { flex: 1; min-width: 8rem; accent-color: var(--gold); }
.controls select { width: auto; }

.wide { flex: 1 1 100%; }

.discover-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) 2fr;
  gap: 2rem;
}
@media (max-width: 800px) { .discover-grid { grid-template-columns: 1fr; } }

#seq-result button { margin-left: 0.5rem; padding: 0.2rem 0.6rem; font-size: 0.85rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.6rem;
}

.g-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  padding: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}
.g-item strong { color: var(--ink); font-weight: 600; }
.g-item canvas {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 4px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
}

footer {
  max-width: 44rem;
  margin: 2rem auto 3rem;
  padding: 0 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
footer a { color: var(--gold-dim); }

@media (max-width: 640px) {
  header { padding-top: 1.5rem; }
  .card { flex-basis: 100%; }
}
