:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #020617;
  color: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #020617;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 100vh;
}

.controls {
  padding: 1.5rem;
  background: #020617;
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  overflow-y: auto;
  position: relative;
}

.controls h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: #cbd5f5;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.6);
  color: inherit;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-row input[type="range"] {
  flex: 1;
  accent-color: #60a5fa;
}

.range-row output {
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #cbd5f5;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.color-row input[type="color"] {
  width: 48px;
  height: 32px;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  cursor: pointer;
}

.color-row span {
  color: #cbd5f5;
  font-size: 0.9rem;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  border-color: rgba(59, 130, 246, 0.6);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}

button {
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(59, 130, 246, 0.25);
  color: #e2e8f0;
  transition: background 0.2s ease;
}

button:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.45);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.experimental-warning {
  text-align: center;
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 0.5rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.reorganise-btn {
  width: 100%;
  margin-top: 0.75rem;
  background: rgba(139, 92, 246, 0.25);
}

.reorganise-btn:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.45);
}

.status {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.5rem;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  padding-bottom: 0.45rem;
}

.stat .label {
  color: #94a3b8;
  font-size: 0.85rem;
}

.feedback {
  min-height: 1.25rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #f9a8d4;
}

.feedback.success {
  color: #bbf7d0;
}

.log {
  margin-top: 1.75rem;
}

.log h2,
.about h2 {
  font-size: 1rem;
  margin-bottom: 0.65rem;
}

#visit-log {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0;
  display: grid;
  gap: 0.35rem;
  max-height: 220px;
  overflow-y: auto;
}

#visit-log li a {
  color: #60a5fa;
  text-decoration: none;
}

#visit-log li a:hover {
  text-decoration: underline;
}

#visit-log li .visit-meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.7rem;
  color: #94a3b8;
}

.about {
  margin-top: 1.75rem;
  font-size: 0.9rem;
  color: #cbd5f5;
}

.visualisation {
  position: relative;
  background: #020617;
}

#graph {
  position: absolute;
  inset: 0;
}

svg {
  width: 100%;
  height: 100%;
  font-family: inherit;
}

.links line {
  stroke: #ffffff;
  stroke-width: 1px;
}

.links line.walk {
  stroke: #ffffff;
}

.links line.similarity {
  stroke: #00ff00;
  stroke-dasharray: 3 4;
}

.nodes circle {
  stroke: rgba(226, 232, 240, 0.9);
  stroke-width: 1.2px;
}

.nodes circle.revisited {
  stroke-width: 2px;
}

.nodes circle.path-highlight {
  filter: drop-shadow(0 0 8px #fbbf24) drop-shadow(0 0 16px #fbbf24);
}

.links line.path-highlight {
  stroke: #fbbf24 !important;
  stroke-width: 2.5px !important;
  filter: drop-shadow(0 0 6px #fbbf24);
  stroke-dasharray: none !important;
}

.labels text {
  fill: rgba(226, 232, 240, 0.9);
  font-size: 0.75rem;
  pointer-events: none;
  text-anchor: middle;
}

.icon-button {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(37, 99, 235, 0.2);
  color: #e2e8f0;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.icon-button:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.45);
}

.home-button {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(34, 197, 94, 0.25);
  color: #e2e8f0;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  z-index: 10;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.home-button:hover {
  background: rgba(34, 197, 94, 0.45);
  border-color: rgba(34, 197, 94, 0.6);
  transform: scale(1.1);
}

.home-button:active {
  transform: scale(0.95);
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .controls {
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  }
}
