:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --background-color: #0f172a;
  --surface-color: #111827;
  --panel-color: #1f2937;
  --text-color: #e5e7eb;
  --text-muted: #9ca3af;
  --edge-color: #6b7280;
  --node-color: #3b82f6;
  --error-color: #ef4444;
  --input-bg: #0b1222;
  --input-border: #1f2937;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(16, 185, 129, 0.08), transparent 25%),
    var(--background-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.app-container {
  width: 100%;
  max-width: 1600px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.title-row {
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(90deg, #3b82f6, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 0.5rem 0;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.matrix-panel {
  background: var(--surface-color);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
}

.matrix-panel h2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-color);
}

.instructions {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.instructions strong {
  color: var(--primary-color);
  font-weight: 600;
}

#matrix-container {
  overflow-x: auto;
}

.matrix-table {
  display: inline-block;
}

.matrix-row {
  display: flex;
  gap: 2px;
}

.matrix-row.header-row {
  margin-bottom: 2px;
}

.matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.corner-cell {
  width: 42px;
  height: 42px;
}

.header-cell {
  width: 42px;
  height: 42px;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.95rem;
}

.matrix-input {
  width: 42px;
  height: 42px;
  text-align: center;
  padding: 0;
  border-radius: 0.25rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}

.matrix-input:not(:disabled):hover {
  border-color: var(--primary-color);
  background: #0f1829;
}

.matrix-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.matrix-input.diagonal {
  background: #0a0e1a;
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.visualization-panel {
  background: var(--surface-color);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.visualization-panel h2 {
  font-size: 1.5rem;
  color: var(--text-color);
  margin: 0;
}

.visualization-area {
  background: var(--panel-color);
  border-radius: 0.75rem;
  min-height: 500px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--input-border);
}

#graph-container {
  position: relative;
  width: 100%;
  height: 500px;
}

.node {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: 3px solid #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: transform 0.2s;
  z-index: 10;
  cursor: pointer;
}

.node:hover {
  transform: scale(1.1);
}

.edge {
  position: absolute;
  height: 3px;
  background: linear-gradient(90deg, var(--edge-color), #9ca3af);
  transform-origin: 0 50%;
  opacity: 0.7;
  z-index: 1;
  transition: opacity 0.2s;
  cursor: pointer;
}

.edge:hover {
  opacity: 1;
}

.edge-weight {
  position: absolute;
  background: linear-gradient(135deg, #1f2937, #111827);
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 2px solid #fbbf24;
  transform: translate(-50%, -50%);
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.edge-weight:hover {
  background: linear-gradient(135deg, #374151, #1f2937);
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.info-panel {
  background: var(--panel-color);
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--input-border);
}

#status-message {
  font-size: 0.95rem;
  color: var(--text-color);
}

#status-message.error {
  color: var(--error-color);
}

@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .matrix-panel {
    order: 2;
  }

  .visualization-panel {
    order: 1;
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  .tagline {
    font-size: 0.9rem;
  }

  .matrix-panel,
  .visualization-panel {
    padding: 1rem;
  }

  #graph-container {
    height: 400px;
  }
}