/* Transformer Attention (Q,K,V) Tutorial - Real 512D Embeddings
   Max width: 800px, Font: Courier New, Background: Black
   Scoped to #att-sim to avoid global collision */
#att-sim {
  max-width: 800px;
  margin: 0 auto;
  font-family: 'Courier New', Courier, monospace;
  background: #000;
  color: #eee;
  padding: 12px;
  box-sizing: border-box;
}

#att-sim * {
  box-sizing: border-box;
}

#att-sim .att-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#att-sim .att-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#att-sim .att-label {
  min-width: 120px;
  color: #0f0;
  font-size: 12px;
}

#att-sim .att-input-words {
  flex: 1;
  min-width: 200px;
  height: 28px;
  line-height: 1.2;
  background: #111;
  color: #0f0;
  border: 1px solid #444;
  padding: 4px 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  resize: none;
}

#att-sim .att-btn {
  background: #333;
  color: #0f0;
  border: 1px solid #555;
  padding: 8px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  cursor: pointer;
}

#att-sim .att-btn:hover {
  background: #444;
  border-color: #0f0;
}

#att-sim .att-status {
  font-size: 12px;
  color: #888;
}

#att-sim .att-slider {
  width: 120px;
  accent-color: #0f0;
  vertical-align: middle;
}

#att-sim .att-temperature-value {
  font-size: 12px;
  color: #0f0;
  min-width: 3em;
  display: inline-block;
}

#att-sim .att-head-type {
  min-width: 160px;
  padding: 4px 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  background: #111;
  color: #eee;
  border: 1px solid #444;
  border-radius: 2px;
}
#att-sim .att-head-type.att-head-semantic { border-color: #0f0; color: #0f0; }
#att-sim .att-head-type.att-head-positional { border-color: #0af; color: #0af; }
#att-sim .att-head-type.att-head-identity { border-color: #fa0; color: #fa0; }

#att-sim .att-checkbox-label {
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#att-sim .att-mask-self {
  accent-color: #0f0;
  cursor: pointer;
}

#att-sim .att-canvas-wrap {
  position: relative;
  width: 100%;
  min-width: 400px;
  max-width: 800px;
  min-height: 500px;
  background: #000;
  border: 1px solid #444;
}

#att-sim #att-vizCanvas {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  height: 500px;
  display: block;
  cursor: pointer;
}

#att-sim .att-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(0,0,0,0.9);
  color: #0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-size: 12px;
}


#att-sim .att-hint {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

/* Softmax Heatmap Panel */
#att-sim .att-heatmap-panel {
  margin-top: 8px;
  border: 1px solid #444;
  background: #111;
  padding: 8px;
}

#att-sim .att-heatmap-panel h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #0f0;
}

#att-sim .att-heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

#att-sim .att-heatmap-table th,
#att-sim .att-heatmap-table td {
  padding: 4px 8px;
  text-align: left;
  border: 1px solid #333;
}

#att-sim .att-heatmap-table th {
  background: #222;
  color: #0f0;
}

#att-sim .att-heatmap-table td {
  color: #ccc;
}

#att-sim .att-heatmap-table .att-bar-cell {
  width: 120px;
}

#att-sim .att-softmax-bar {
  height: 14px;
  background: linear-gradient(90deg, #003322, #00ffcc);
  transition: width 0.3s ease;
  min-width: 2px;
}

#att-sim .att-focus-label {
  color: #ffcc00;
  font-weight: bold;
}

/* Q, K, V role colors in heatmap */
#att-sim .att-role-q {
  color: #ffcc00;
  font-weight: bold;
}

#att-sim .att-role-k {
  color: #00ffcc;
}

/* Top contextual (non-query) match — semantic best match glow */
#att-sim .att-best-match {
  box-shadow: inset 0 0 0 1px rgba(0, 255, 204, 0.6);
  background: rgba(0, 255, 204, 0.08);
}
#att-sim .att-heatmap-table tr:hover .att-best-match {
  background: rgba(0, 255, 204, 0.12);
}

#att-sim .att-role-v {
  color: #cc88ff;
}

/* Attention beam glow */
#att-sim .att-beam-line {
  filter: drop-shadow(0 0 4px rgba(0, 255, 204, 0.5));
}

/* Embedding 1D heatmap (horizontal color bar per word) */
#att-sim .att-embedding-bars {
  margin-top: 12px;
  border: 1px solid #444;
  background: #111;
  padding: 8px;
  max-width: 100%;
  overflow: hidden;
}

#att-sim .att-embedding-bars h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #0f0;
}

#att-sim .att-embedding-strip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#att-sim .att-embedding-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  min-width: 0;
}

#att-sim .att-embedding-label {
  flex-shrink: 0;
  min-width: 48px;
  color: #ccc;
}

#att-sim .att-embedding-strip {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  min-height: 14px;
  max-width: 100%;
}

#att-sim .att-embedding-cell {
  flex: 1 1 0;
  min-width: 0;
  height: 14px;
  display: inline-block;
}

/* Transfer pipeline: head aggregation → Z */
#att-sim .att-pipeline-intro {
  font-size: 11px;
  color: #888;
  margin: 0 0 8px 0;
}
#att-sim .att-concatenation-rack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
#att-sim .att-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  min-width: 0;
}
#att-sim .att-head-row .att-embedding-label {
  min-width: 52px;
}
#att-sim .att-head-row.att-head-placeholder .att-embedding-strip {
  opacity: 0.5;
}
#att-sim .att-z-heatmap-frame {
  border: 1px solid #444;
  background: #111;
  padding: 10px 12px;
  margin: 12px 0;
  border-radius: 4px;
}
#att-sim .att-z-heatmap-frame .att-z-heatmap-title {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: #0f0;
}
#att-sim .att-z-heatmap-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 0;
  min-width: 0;
}
#att-sim .att-z-heatmap-frame .att-z-heatmap-row {
  margin-bottom: 0;
}
#att-sim .att-z-heatmap-row .att-z-head-spacer {
  min-width: 52px;
  flex-shrink: 0;
}
#att-sim .att-z-heatmap-frame .att-embedding-strip {
  flex: 1 1 0;
  min-width: 0;
}
#att-sim .att-final-z-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 10px;
  min-width: 0;
  width: 100%;
}
#att-sim .att-final-z-row .att-embedding-label {
  min-width: 72px;
  flex-shrink: 0;
}
#att-sim .att-final-z-row #att-final-output-z.att-embedding-strip {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
}
#att-sim .att-z-strip {
  flex: 1 1 0;
  min-width: 0;
}
#att-sim .att-comparison-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
#att-sim .att-comparison-col {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
#att-sim .att-comparison-col .att-embedding-strip {
  width: 100%;
}

/* Z (contextualized output) row above Show residual checkbox: label on top, bar below */
#att-sim .att-z-above-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-size: 11px;
  min-width: 0;
}
#att-sim .att-z-above-row .att-embedding-label {
  flex-shrink: 0;
}
#att-sim .att-z-above-row .att-embedding-strip.att-z-below-label {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
}

/* W_Q, W_K, W_V 2D heatmaps */
#att-sim .att-w-heatmaps {
  margin-top: 12px;
  border: 1px solid #444;
  background: #111;
  padding: 8px;
  max-width: 100%;
  overflow: hidden;
}

#att-sim .att-w-heatmaps h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #0f0;
}

#att-sim .att-w-heatmap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
}

#att-sim .att-w-heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#att-sim .att-w-label {
  font-size: 11px;
  color: #0f0;
}

#att-sim .att-w-canvas {
  display: block;
  border: 1px solid #333;
  max-width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* W_O heatmap (below Final Z in transfer pipeline) */
#att-sim .att-wo-heatmap-wrap {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #444;
  background: #111;
  max-width: 100%;
}

#att-sim .att-wo-heatmap-title {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: #0f0;
}

#att-sim .att-wo-heatmap-cell {
  display: flex;
  justify-content: flex-start;
}

#att-sim .att-wo-canvas {
  display: block;
  border: 1px solid #333;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
