/* ============================================================================
   MicroDiffusion LM — Web Demo Styles
   Terminal-inspired dark theme with clean typography
   ============================================================================ */

/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-panel: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-muted: #484f58;

  --cyan: #58a6ff;
  --cyan-dim: #264f78;
  --magenta: #d2a8ff;
  --magenta-dim: #553d73;
  --green: #3fb950;
  --green-bright: #56d364;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --blue: #58a6ff;

  --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --radius: 8px;
  --radius-lg: 12px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  padding: 0 1rem;
}

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

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

.badges {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2em 0.65em;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-red    { background: #f8514922; color: #f85149; border: 1px solid #f8514944; }
.badge-blue   { background: #58a6ff22; color: #58a6ff; border: 1px solid #58a6ff44; }
.badge-green  { background: #3fb95022; color: #3fb950; border: 1px solid #3fb95044; }
.badge-purple { background: #d2a8ff22; color: #d2a8ff; border: 1px solid #d2a8ff44; }

/* ─── Controls ─── */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  max-width: 700px;
  margin: 0 auto;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: linear-gradient(135deg, #238636, #2ea043);
  border: 1px solid #238636;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2ea043, #3fb950);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 160, 67, 0.3);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary.running {
  background: linear-gradient(135deg, #b62324, #da3633);
  border-color: #da3633;
}
.btn-primary.running:hover:not(:disabled) {
  background: linear-gradient(135deg, #da3633, #f85149);
  box-shadow: 0 4px 12px rgba(248, 81, 73, 0.3);
}

.btn-icon {
  font-size: 0.9rem;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.speed-control label {
  font-weight: 500;
}

.speed-control input[type="range"] {
  width: 100px;
  accent-color: var(--cyan);
}

#speed-label {
  font-family: var(--font-mono);
  min-width: 3.5em;
  font-size: 0.8rem;
}

/* ─── Race Arena ─── */
.race-arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 1100px;
  margin: 0.5rem auto 1rem;
}

@media (max-width: 768px) {
  .race-arena {
    grid-template-columns: 1fr;
  }
}

/* ─── Panels ─── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.8rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.panel-diffusion .panel-title { color: var(--cyan); }
.panel-gpt .panel-title { color: var(--magenta); }

.panel-icon {
  font-size: 1.1rem;
}

.panel-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15em 0.55em;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: auto;
}
.panel-diffusion .panel-badge {
  background: var(--cyan-dim);
  color: var(--cyan);
}
.panel-gpt .panel-badge {
  background: var(--magenta-dim);
  color: var(--magenta);
}

.panel-badge.done {
  background: #23863633;
  color: var(--green-bright);
}

.panel-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ─── Progress Bar ─── */
.progress-bar-container {
  position: relative;
  height: 22px;
  background: var(--bg);
  margin: 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  transition: width 0.05s linear;
  border-radius: 0;
}
.progress-bar-diff {
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
}
.progress-bar-gpt {
  background: linear-gradient(90deg, var(--magenta-dim), var(--magenta));
}

.progress-text {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ─── Output Text ─── */
.output-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 0.8rem 1rem;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
}

.placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Token styling via spans */
.tok-prompt  { color: #fff; font-weight: 600; }
.tok-mask    { color: var(--text-muted); }
.tok-new     { color: var(--green-bright); font-weight: 600; }
.tok-revealed { color: var(--yellow); }
.tok-gpt-gen { color: var(--cyan); }
.tok-gpt-new { color: var(--green-bright); font-weight: 600; }

/* ─── Speedup Banner ─── */
.speedup-banner {
  text-align: center;
  padding: 0.8rem;
  margin: 0 auto 1rem;
  max-width: 600px;
  background: #23863622;
  border: 1px solid #23863644;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  color: var(--green-bright);
  animation: fadeInUp 0.4s ease;
}

.speedup-icon {
  margin-right: 0.3rem;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Info Section ─── */
.info-section {
  max-width: 1100px;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.info-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.8rem;
}

.card-footer {
  margin-top: 0.8rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ─── Diff Table ─── */
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.diff-table th,
.diff-table td {
  padding: 0.45rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.diff-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.diff-table td:first-child {
  color: var(--text-muted);
  font-family: var(--font-mono);
  width: 2rem;
}

.diff-table td:nth-child(3) { color: var(--magenta); }
.diff-table td:nth-child(4) { color: var(--cyan); }

/* ─── How It Works ─── */
.how-it-works {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 600px) {
  .how-it-works { grid-template-columns: 1fr; }
}

.how-col h4 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.how-col p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.step-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem !important;
  color: var(--text) !important;
  margin-top: 0.3rem !important;
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Scrollbar ─── */
.output-text::-webkit-scrollbar {
  width: 6px;
}
.output-text::-webkit-scrollbar-track {
  background: transparent;
}
.output-text::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
