/* ============================================================
   Text Vectorization Lab — design tokens
   ============================================================ */
:root{
  --bg:            #0a0d13;
  --bg-grid:       #0c1019;
  --surface:       #131826;
  --surface-2:     #1a2133;
  --surface-3:     #212a40;
  --border:        #283149;
  --border-soft:   #1c2335;

  --text-1:        #eef1f7;
  --text-2:        #a4adc4;
  --text-3:        #6b7390;

  --amber:         #f2a93b;
  --amber-dim:     #f2a93b22;
  --teal:          #34d6b8;
  --teal-dim:      #34d6b822;
  --pink:          #ef5da8;
  --pink-dim:      #ef5da822;
  --violet:        #9b8cf2;
  --violet-dim:    #9b8cf222;

  --font-display:  'Fraunces', Georgia, serif;
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:     'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px -12px rgba(0,0,0,0.6);
}

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

body{
  background: var(--bg);
  background-image:
    radial-gradient(circle at 0px 0px, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a{ color: var(--teal); text-decoration:none; }
::selection{ background: var(--amber-dim); }

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover{ background: var(--border); }

h1,h2,h3,h4{ font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--text-1); }
code, .mono{ font-family: var(--font-mono); }

button{ font-family: inherit; cursor: pointer; }

/* ============================================================
   App shell
   ============================================================ */
.app{
  display:grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar{
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-grid), var(--bg));
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 0 8px 22px 8px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.brand-mark{
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), var(--pink));
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: #1a1108;
  flex: none;
}
.brand-text{ line-height:1.25; }
.brand-title{ font-family: var(--font-display); font-size: 16px; font-weight:600; }
.brand-sub{ font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); letter-spacing:.04em; text-transform:uppercase; }

.nav-group-label{
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 14px 10px 8px;
}

.nav-item{
  display:flex;
  align-items:center;
  gap: 11px;
  width: 100%;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: 13.5px;
  text-align:left;
  margin-bottom: 2px;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item .nav-idx{
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  width: 18px;
  flex: none;
}
.nav-item:hover{ background: var(--surface); color: var(--text-1); }
.nav-item.active{
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-1);
}
.nav-item.active .nav-idx{ color: var(--amber); }
.nav-item.active::after{ content:''; }

.sidebar-foot{
  margin-top: 22px;
  padding: 12px 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-3);
}
.sidebar-foot .pulse-dot{
  display:inline-block; width:7px; height:7px; border-radius:50%;
  background: var(--teal); margin-right:6px;
  box-shadow: 0 0 0 0 var(--teal-dim);
  animation: pulse 2s infinite;
}
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(52,214,184,.5); }
  70%{ box-shadow: 0 0 0 6px rgba(52,214,184,0); }
  100%{ box-shadow: 0 0 0 0 rgba(52,214,184,0); }
}

/* ---- Main ---- */
.main{ padding: 36px 44px 80px; max-width: 1080px; }

.page-header{ margin-bottom: 26px; }
.eyebrow{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
}
.page-title{ font-size: 32px; margin-bottom: 10px; }
.page-desc{ color: var(--text-2); max-width: 680px; font-size: 14.5px; }

.section{ display:none; }
.section.active{ display:block; animation: fadeUp .35s ease; }
@keyframes fadeUp{ from{ opacity:0; transform: translateY(6px);} to{ opacity:1; transform:none; } }

/* ============================================================
   Pipeline tape — signature element
   ============================================================ */
.tape{
  display:flex;
  align-items:center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 6px;
  margin-bottom: 26px;
  overflow-x: auto;
}
.tape-stage{
  flex: 1;
  display:flex;
  align-items:center;
  gap:8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12.5px;
  font-family: var(--font-mono);
  position:relative;
  transition: color .2s, background .2s;
}
.tape-stage .dot{ width:6px; height:6px; border-radius:50%; background: var(--text-3); flex:none; transition: background .2s, box-shadow .2s; }
.tape-stage.done{ color: var(--text-2); }
.tape-stage.done .dot{ background: var(--teal); }
.tape-stage.current{ color: var(--text-1); background: var(--surface-3); }
.tape-stage.current .dot{ background: var(--amber); box-shadow: 0 0 0 4px var(--amber-dim); }
.tape-arrow{ color: var(--text-3); flex: none; padding: 0 2px; font-size:13px; }

/* ============================================================
   Cards / panels
   ============================================================ */
.card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}
.card-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title{ font-size: 15px; font-weight:600; font-family: var(--font-body); color: var(--text-1); display:flex; align-items:center; gap:8px; }
.card-title .step-num{
  font-family: var(--font-mono); font-size: 11px; color: var(--amber);
  border: 1px solid var(--amber-dim); background: var(--amber-dim);
  border-radius: 5px; padding: 2px 6px;
}
.card-note{ font-size: 12.5px; color: var(--text-3); }

.field-row{ display:flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.field{ flex: 1; min-width: 220px; }
.field label{ display:block; font-size: 11.5px; color: var(--text-3); margin-bottom:6px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }
textarea, input[type=text], input[type=number]{
  width: 100%;
  background: var(--bg-grid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
}
textarea:focus, input:focus{ outline: 2px solid var(--teal-dim); border-color: var(--teal); }
textarea{ min-height: 92px; line-height: 1.5; }

.checkbox-row{ display:flex; align-items:center; gap:8px; font-size: 13px; color: var(--text-2); }
.checkbox-row input{ width:auto; accent-color: var(--teal); }

.btn{
  display:inline-flex; align-items:center; gap:8px;
  background: var(--amber);
  color: #1a1108;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover{ transform: translateY(-1px); box-shadow: 0 6px 18px -8px var(--amber-dim); }
.btn:active{ transform: translateY(0); }
.btn:disabled{ opacity:.55; cursor: default; transform:none; }
.btn-ghost{
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
}
.btn-ghost:hover{ color: var(--text-1); border-color: var(--text-3); }
.btn-sm{ padding: 7px 12px; font-size: 12.5px; }

.btn-row{ display:flex; gap:10px; align-items:center; flex-wrap: wrap; }

.spinner{
  width:14px; height:14px; border-radius:50%;
  border: 2px solid rgba(0,0,0,.25); border-top-color: #1a1108;
  animation: spin .7s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ============================================================
   Steps output
   ============================================================ */
.steps{ display:flex; flex-direction:column; gap: 16px; }
.step{
  opacity: 0; transform: translateY(8px);
  border-left: 2px solid var(--border);
  padding-left: 16px;
  transition: opacity .4s ease, transform .4s ease;
}
.step.show{ opacity:1; transform:none; }
.step-label{ font-family: var(--font-mono); font-size: 11.5px; color: var(--amber); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.step-body{ color: var(--text-2); font-size: 13.5px; }

/* token chips */
.chip-row{ display:flex; flex-wrap:wrap; gap:7px; }
.chip{
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 11px; color: var(--text-1);
  opacity: 0; transform: scale(.85);
  animation: chipIn .3s ease forwards;
}
@keyframes chipIn{ to{ opacity:1; transform:none; } }
.chip.amber{ border-color: var(--amber-dim); background: var(--amber-dim); color: var(--amber); }
.chip.teal{ border-color: var(--teal-dim); background: var(--teal-dim); color: var(--teal); }
.chip.pink{ border-color: var(--pink-dim); background: var(--pink-dim); color: var(--pink); }
.chip.violet{ border-color: var(--violet-dim); background: var(--violet-dim); color: var(--violet); }
.chip.muted{ color: var(--text-3); }

/* matrix tables */
.table-wrap{ overflow-x:auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }
table.matrix{ border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 12.5px; }
table.matrix th, table.matrix td{
  padding: 8px 11px; text-align:center; border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft); white-space: nowrap;
}
table.matrix th{ background: var(--surface-2); color: var(--text-2); font-weight:500; }
table.matrix td.row-head{ background: var(--surface-2); color: var(--text-2); text-align:left; font-weight:500; }
table.matrix tr:last-child td{ border-bottom:none; }
table.matrix th:last-child, table.matrix td:last-child{ border-right:none; }
.cell{
  opacity:0; animation: cellIn .3s ease forwards;
}
@keyframes cellIn{ to{ opacity:1; } }
.cell-fill{ display:inline-block; min-width: 22px; padding: 2px 6px; border-radius: 5px; }

/* heat coloring applied inline via JS rgba */

.formula{
  font-family: var(--font-mono);
  background: var(--bg-grid);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--teal);
  overflow-x:auto;
}
.formula .dim{ color: var(--text-3); }

.kv-list{ display:flex; flex-direction:column; gap:6px; }
.kv-row{ display:flex; justify-content:space-between; gap:12px; font-family: var(--font-mono); font-size: 12.5px; padding: 6px 10px; border-radius: 6px; background: var(--bg-grid); }
.kv-row .k{ color: var(--text-2); }
.kv-row .v{ color: var(--teal); font-weight:600; }

.callout{
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
}
.callout strong{ color: var(--text-1); }
.callout.warn{ border-color: var(--pink-dim); background: var(--pink-dim); color: #ffd9ea; }
.callout.warn strong{ color: var(--pink); }

.two-col{ display:grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px){ .two-col{ grid-template-columns: 1fr; } }

.legend{ display:flex; gap:16px; flex-wrap:wrap; font-size: 12px; color: var(--text-3); margin-top:10px; }
.legend span{ display:inline-flex; align-items:center; gap:6px; }
.legend .sw{ width:12px; height:12px; border-radius:3px; display:inline-block; }

.empty-hint{ color: var(--text-3); font-size: 13px; font-style: italic; }

.compare-table{ width:100%; border-collapse: collapse; font-size: 13px; }
.compare-table th, .compare-table td{ padding: 9px 12px; border-bottom: 1px solid var(--border-soft); text-align:left; }
.compare-table th{ color: var(--text-3); font-family: var(--font-mono); font-size: 11px; text-transform:uppercase; letter-spacing:.04em; }
.compare-table td{ color: var(--text-2); }
.compare-table tr:hover td{ background: var(--surface-2); }

/* scatter plot */
.scatter-wrap{ background: var(--bg-grid); border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: 8px; }
.scatter-wrap svg text{ font-family: var(--font-mono); }

/* overview cards */
.tech-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
@media (max-width: 900px){ .tech-grid{ grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px){ .tech-grid{ grid-template-columns: 1fr; } }
.tech-card{
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align:left;
  color: var(--text-2);
  transition: border-color .15s, transform .15s;
}
.tech-card:hover{ border-color: var(--amber-dim); transform: translateY(-2px); }
.tech-card .n{ font-family: var(--font-mono); color: var(--amber); font-size: 11px; }
.tech-card h4{ margin: 6px 0 6px; font-size: 15px; color: var(--text-1); }
.tech-card p{ margin:0; font-size: 12.5px; color: var(--text-3); }

footer.colophon{ margin-top: 50px; padding-top: 18px; border-top: 1px solid var(--border-soft); color: var(--text-3); font-size: 12px; }

/* responsive sidebar */
@media (max-width: 880px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ position: relative; height: auto; display:flex; flex-direction: column; }
  .main{ padding: 26px 18px 60px; }
}