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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f1117;
  color: #e8e8e8;
  overflow: hidden;
  height: 100vh;
}

/* ── Header ── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 52px;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2a2d3a;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

#header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #a0c4ff;
}

.legend {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-size: 0.8rem;
  color: #8a8fa8;
}

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

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

.legend-dot.axiom  { background: #4a90d9; }
.legend-dot.theorem { background: #e8a838; }

/* ── Graph canvas ── */
#graph-container {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
}

#graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-svg:active {
  cursor: grabbing;
}

/* ── Label overlay ── */
#label-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-origin: 0 0;
  overflow: visible;
  z-index: 1;
}

/* Nodes */
.node circle {
  stroke: #fff;
  stroke-width: 1.5px;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.25s ease;
}

.node circle:hover {
  filter: brightness(1.3) drop-shadow(0 0 8px currentColor);
}

.node-label {
  position: absolute;
  width: 120px;
  color: #e8e8e8;
  font-size: 11px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.35;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.25s ease;
}

.node-label .katex {
  font-size: 11px;
  color: #e8e8e8;
}

/* Edges */
.edge {
  stroke: #3a3d4f;
  stroke-width: 1.5px;
  transition: opacity 0.25s ease, stroke-width 0.25s ease;
}


/* ── Proof panel ── */
#proof-panel {
  position: fixed;
  top: 52px;
  right: -440px;
  width: 420px;
  bottom: 0;
  background: #161921;
  border-left: 1px solid #2a2d3a;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

#proof-panel.open {
  right: 0;
  transform: translateX(0);
}

#panel-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2a2d3a;
  gap: 0.75rem;
  flex-shrink: 0;
}

#panel-type-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

#panel-type-badge.axiom    { background: rgba(74, 144, 217, 0.2); color: #4a90d9; border: 1px solid #4a90d9; }
#panel-type-badge.theorem  { background: rgba(232, 168, 56, 0.2); color: #e8a838; border: 1px solid #e8a838; }

#panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
  line-height: 1.3;
}

#panel-close {
  background: none;
  border: none;
  color: #8a8fa8;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

#panel-close:hover {
  color: #e8e8e8;
  background: #2a2d3a;
}

#panel-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  line-height: 1.7;
  font-size: 0.9rem;
}

/* Markdown rendered content */
#panel-body h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #c8d0e8;
}

#panel-body p {
  margin-bottom: 0.75rem;
  color: #b8bdd4;
}

#panel-body strong {
  color: #e8e8e8;
}

#panel-body .katex {
  color: #e8e0c0;
}

#panel-body .katex-display {
  margin: 0.75rem 0;
  overflow-x: auto;
}

#panel-body a[href^="#"] {
  color: #7ab8f5;
  text-decoration: underline dotted;
  cursor: pointer;
}

#panel-body a[href^="#"]:hover {
  color: #a8d0ff;
}

/* ── Search ── */
.search-wrapper {
  position: relative;
  margin-left: 1rem;
}

#search-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #2a2d3a;
  border-radius: 4px;
  color: #e8e8e8;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 5px 10px;
  width: 180px;
  outline: none;
  transition: border-color 0.2s, width 0.2s;
}

#search-input::placeholder {
  color: #4a4f68;
}

#search-input:focus {
  border-color: #4a90d9;
  width: 260px;
}

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: #161921;
  border: 1px solid #2a2d3a;
  border-radius: 6px;
  display: none;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #1e2130;
  transition: background 0.15s;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background: rgba(74, 144, 217, 0.1);
}

.search-item-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.search-item-badge.axiom {
  background: rgba(74, 144, 217, 0.2);
  color: #4a90d9;
}

.search-item-badge.theorem {
  background: rgba(232, 168, 56, 0.2);
  color: #e8a838;
}

.search-item-title {
  font-size: 0.85rem;
  color: #e8e8e8;
}

.search-item-snippet {
  font-size: 0.75rem;
  color: #6a6f88;
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Language switcher ── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  margin-left: 1rem;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  color: #4a4f68;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.lang-btn:hover {
  color: #8a8fa8;
}

.lang-btn.active {
  color: #a0c4ff;
  border-color: #2a4060;
  background: rgba(74, 144, 217, 0.1);
}

/* ── Hint ── */
#hint {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: #4a4f68;
  font-size: 0.8rem;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
