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

body {
  background: #0a0e1a;
  color: #e0e6f0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#header {
  position: fixed;
  top: 0;
  left: 80px;
  right: 0;
  padding: 18px 30px;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(10, 14, 26, 0.95) 60%, transparent);
  pointer-events: none;
}

#header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  pointer-events: auto;
}

#header h1 .subtitle {
  font-weight: 300;
  opacity: 0.6;
  margin-left: 8px;
}

.tagline {
  font-size: 0.8rem;
  opacity: 0.4;
  margin-top: 4px;
  font-style: italic;
}

#legend {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.9;
  background: rgba(10, 14, 26, 0.85);
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  z-index: 100;
}

.legend-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.5;
  margin-bottom: 4px;
}

.legend-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.arrow-icon {
  font-size: 1rem;
  font-weight: 900;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-bool { background: #66bb6a; box-shadow: 0 0 6px #66bb6a; }
.dot-integer { background: #4fc3f7; box-shadow: 0 0 6px #4fc3f7; }
.dot-float { background: #ab47bc; box-shadow: 0 0 6px #ab47bc; }
.dot-theorem { background: #ffd54f; box-shadow: 0 0 6px #ffd54f; }

.hex {
  width: 12px;
  height: 10px;
  background: #ffd54f;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 6px #ffd54f;
}

.line-sample {
  width: 20px;
  height: 2px;
  display: inline-block;
}

.line-lossless { background: #4caf50; box-shadow: 0 0 4px #4caf50; }
.line-lossy { background: #ff7043; box-shadow: 0 0 4px #ff7043; opacity: 0.6; }
.line-proves { background: #ffd54f; box-shadow: 0 0 4px #ffd54f; }
.line-depends { background: #78909c; box-shadow: 0 0 4px #78909c; opacity: 0.5; }

#stats {
  margin-top: 10px;
  font-size: 0.75rem;
  opacity: 0.5;
  pointer-events: auto;
}

#progress-bar {
  position: fixed;
  top: 60px;
  left: 50px;
  bottom: 60px;
  width: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  z-index: 200;
  overflow: hidden;
}

#progress-fill {
  width: 100%;
  background: linear-gradient(180deg, #4fc3f7, #ab47bc, #ffd54f);
  box-shadow: 0 0 12px rgba(171, 71, 188, 0.6), inset 1px 0 0 rgba(255,255,255,0.2);
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 9px;
}

#progress-lambda {
  position: fixed;
  left: 38px;
  font-size: 52px;
  font-weight: 900;
  color: #ff1744;
  text-shadow: 0 0 10px #ff1744, 0 0 24px rgba(255, 23, 68, 0.5), 0 0 40px rgba(255, 23, 68, 0.2);
  -webkit-text-stroke: 2px #000;
  cursor: grab;
  z-index: 300;
  user-select: none;
  touch-action: none;
  line-height: 1;
  transform: translateY(-50%);
  transition: none;
}

#progress-lambda:active {
  cursor: grabbing;
}

#progress-timestamp {
  position: fixed;
  left: 80px;
  background: rgba(10, 14, 26, 0.92);
  border: 1px solid rgba(255, 213, 79, 0.3);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffd54f;
  z-index: 250;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  transform: translateY(-50%);
}

#progress-timestamp.visible {
  opacity: 1;
}

#scrub-hint {
  position: fixed;
  left: 80px;
  padding: 12px 18px 12px 14px;
  background: rgba(255, 253, 240, 0.95);
  border: none;
  border-radius: 20px 20px 20px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #333;
  z-index: 301;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  transform: translateY(-50%);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 -2px 4px rgba(0,0,0,0.05);
  filter: drop-shadow(0 0 6px rgba(255, 213, 79, 0.3));
}

#graph {
  width: 100vw;
  height: 100vh;
  display: block;
}

#tooltip {
  position: fixed;
  padding: 10px 14px;
  background: rgba(20, 25, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 200;
  max-width: 260px;
  backdrop-filter: blur(8px);
}

#tooltip.visible {
  opacity: 1;
}

#tooltip .tt-title {
  font-weight: 700;
  margin-bottom: 4px;
}

#tooltip .tt-status {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#tooltip .tt-status.complete { background: rgba(76, 175, 80, 0.3); color: #81c784; }
#tooltip .tt-status.in_progress { background: rgba(255, 183, 77, 0.3); color: #ffb74d; }
#tooltip .tt-status.planned { background: rgba(120, 120, 140, 0.3); color: #9e9e9e; }

#tooltip .tt-pr {
  margin-top: 6px;
  opacity: 0.7;
}

#tooltip .tt-pr a {
  color: #64b5f6;
  text-decoration: none;
}

#tooltip .tt-cites {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

#tooltip .tt-cite {
  margin-top: 4px;
  font-size: 0.68rem;
  line-height: 1.4;
}

#tooltip .tt-cite a {
  color: #ff8a65;
  text-decoration: none;
  font-weight: 700;
}

.cite-badge {
  filter: drop-shadow(0 0 4px rgba(255, 138, 101, 0.5));
}

/* Bit layout panel */
#bit-panel {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 18px 24px;
  z-index: 250;
  backdrop-filter: blur(10px);
  min-width: 300px;
  max-width: 600px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#bit-panel.visible {
  opacity: 1;
  pointer-events: auto;
}

#bit-panel-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

#bit-panel-layout {
  display: flex;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.bit-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  position: relative;
  min-width: 20px;
}

.bit-segment-label {
  position: absolute;
  bottom: -16px;
  font-size: 0.6rem;
  opacity: 0.7;
  white-space: nowrap;
}

#bit-panel-details {
  margin-top: 18px;
  font-size: 0.75rem;
  opacity: 0.7;
  line-height: 1.6;
}

#bit-converter {
  margin-top: 14px;
  display: none;
}

#bit-converter.visible {
  display: block;
}

#bit-converter-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 12px;
  color: #e0e6f0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

#bit-converter-input:focus {
  border-color: rgba(79, 195, 247, 0.5);
}

#bit-converter-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#bit-converter-bits {
  margin-top: 8px;
  display: flex;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  gap: 1px;
  flex-wrap: wrap;
}

.bit-char {
  width: 16px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: background 0.15s;
}

.bit-char.spacer {
  width: 6px;
  background: none !important;
}

#bit-converter-info {
  margin-top: 6px;
  font-size: 0.68rem;
  opacity: 0.6;
  min-height: 1.2em;
}

#bit-panel-edge-cases {
  position: absolute;
  top: 14px;
  right: 40px;
  background: rgba(255, 213, 79, 0.15);
  border: 1px solid rgba(255, 213, 79, 0.4);
  color: #ffd54f;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: none;
}

#bit-panel-edge-cases:hover {
  background: rgba(255, 213, 79, 0.3);
  border-color: rgba(255, 213, 79, 0.7);
}

#bit-panel-edge-cases.visible {
  display: block;
}

#edge-cases-list {
  display: none;
  margin-top: 14px;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

#edge-cases-list.visible {
  display: block;
}

.edge-case-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.edge-case-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.edge-case-status.pass {
  background: #4caf50;
  box-shadow: 0 0 4px #4caf50;
}

.edge-case-status.fail {
  background: #ef5350;
  box-shadow: 0 0 4px #ef5350;
}

.edge-case-input {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #4fc3f7;
  min-width: 70px;
}

.edge-case-arrow {
  opacity: 0.4;
}

.edge-case-result {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #81c784;
}

.edge-case-note {
  opacity: 0.5;
  margin-left: auto;
  text-align: right;
  font-size: 0.62rem;
}

#bit-panel-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

#bit-panel-close:hover {
  opacity: 1;
}

/* Proof replay modal */
#proof-replay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 14, 26, 0.97);
  border: 1px solid rgba(255, 213, 79, 0.3);
  border-radius: 14px;
  padding: 0;
  z-index: 400;
  backdrop-filter: blur(12px);
  width: 520px;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  box-shadow: 0 0 40px rgba(255, 213, 79, 0.1);
}

#proof-replay.visible {
  opacity: 1;
  pointer-events: auto;
}

#proof-replay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#proof-replay-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffd54f;
}

#proof-replay-close {
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  line-height: 1;
}

#proof-replay-close:hover {
  opacity: 1;
}

#proof-replay-body {
  padding: 20px;
  min-height: 160px;
}

#proof-replay-step {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4fc3f7;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#proof-replay-bits {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  min-height: 40px;
}

.proof-bits-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proof-bits-label {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.6;
  min-width: 30px;
  text-align: right;
}

.proof-bits-value {
  display: flex;
  gap: 1px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 700;
}

.proof-bit {
  width: 16px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: background 0.3s, color 0.3s, transform 0.3s;
}

.proof-bit.highlight {
  transform: scale(1.2);
  box-shadow: 0 0 8px currentColor;
}

.proof-bit.spacer {
  width: 6px;
  background: none !important;
}

#proof-replay-explanation {
  font-size: 0.78rem;
  line-height: 1.6;
  opacity: 0.85;
}

#proof-replay-explanation code {
  background: rgba(79, 195, 247, 0.15);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: #4fc3f7;
}

#proof-replay-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#proof-replay-nav button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e6f0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#proof-replay-nav button:hover {
  background: rgba(255, 255, 255, 0.15);
}

#proof-replay-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

#proof-replay-counter {
  font-size: 0.7rem;
  opacity: 0.5;
}

/* PR timeline markers */
#pr-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.pr-marker {
  position: absolute;
  left: -8px;
  width: 34px;
  height: 2px;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: auto;
  cursor: pointer;
}

.pr-marker-label {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

.pr-marker:hover .pr-marker-label {
  color: #fff;
}

/* Node styles */
.node-group { cursor: pointer; }

.node-ring {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
}

.node-fill-bg {
  opacity: 0.15;
}

.node-fill-progress {
  opacity: 0.9;
}

.node-label {
  fill: #e0e6f0;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Edge styles */
.edge-lossless {
  stroke: #4caf50;
  stroke-opacity: 0.5;
  stroke-width: 1.2;
}

.edge-lossy {
  stroke: #ff7043;
  stroke-opacity: 0.3;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  marker-end: none !important;
}

.edge-proves {
  stroke: #ffd54f;
  stroke-opacity: 0.4;
  stroke-width: 1.5;
  stroke-dasharray: 2 4;
}

.edge-depends {
  stroke: #78909c;
  stroke-opacity: 0.25;
  stroke-width: 1;
  stroke-dasharray: 1 3;
}

/* Timeline dimming (lambda scrubber) */
.node-group.timeline-dimmed {
  opacity: 0.12;
  transition: opacity 0.25s ease;
}

.node-group.timeline-visible {
  opacity: 1;
  transition: opacity 0.25s ease;
}

line.timeline-dimmed {
  stroke-opacity: 0.03 !important;
  transition: stroke-opacity 0.25s ease;
}

line.timeline-visible {
  transition: stroke-opacity 0.25s ease;
}

/* Hover dimming */
.node-group.dimmed {
  opacity: 0.15;
  transition: opacity 0.3s;
}

.node-group.highlighted {
  opacity: 1;
  transition: opacity 0.3s;
}

line.dimmed {
  stroke-opacity: 0.03 !important;
  transition: stroke-opacity 0.3s;
}

line.highlighted {
  stroke-opacity: 1 !important;
  stroke-width: 2.5 !important;
  transition: stroke-opacity 0.3s, stroke-width 0.3s;
}

/* Glow animation for recently completed */
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 4px currentColor); }
  50% { filter: drop-shadow(0 0 12px currentColor); }
}

.node-recent .node-ring {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* Background particles */
@keyframes float-up {
  0% { transform: translateY(100vh); opacity: 0; }
  10% { opacity: 0.3; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-10vh); opacity: 0; }
}

.particle {
  position: fixed;
  width: 1px;
  height: 1px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  animation: float-up linear infinite;
  pointer-events: none;
  z-index: -1;
}

/* Mobile responsive */
@media (max-width: 768px) {
  #header {
    left: 10px;
    padding: 12px 14px;
  }

  #header h1 {
    font-size: 1rem;
  }

  #header h1 .subtitle {
    display: none;
  }

  .tagline {
    display: none;
  }

  #stats {
    font-size: 0.65rem;
  }

  #progress-bar {
    left: 10px;
    top: 80px;
    bottom: 40px;
    width: 12px;
  }

  #progress-lambda {
    left: 4px;
    font-size: 36px;
  }

  #progress-timestamp {
    left: 30px;
    font-size: 0.65rem;
  }

  #scrub-hint {
    left: 30px;
    font-size: 0.6rem;
  }

  #legend {
    bottom: 10px;
    right: 10px;
    padding: 10px 14px;
    gap: 6px;
    font-size: 0.65rem;
  }

  .legend-title {
    font-size: 0.6rem;
  }

  .arrow-icon {
    font-size: 0.8rem;
  }

  #bit-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    transform: none;
    min-width: unset;
    max-width: unset;
    padding: 14px 16px;
  }

  #tooltip {
    max-width: 200px;
    font-size: 0.7rem;
  }

  .node-label {
    font-size: 7px;
  }

  .pr-marker-label {
    display: none;
  }

  .cite-badge {
    display: none;
  }
}

@media (max-width: 480px) {
  #header h1 {
    font-size: 0.9rem;
  }

  #legend {
    bottom: 6px;
    right: 6px;
    padding: 8px 10px;
    gap: 4px;
    font-size: 0.6rem;
  }

  #progress-lambda {
    font-size: 28px;
    left: 0;
  }

  #progress-bar {
    left: 6px;
    width: 10px;
    top: 70px;
    bottom: 30px;
  }

  .node-label {
    font-size: 6px;
  }
}
