:root {
      --bg: #f8fafc;
      --card: rgba(255, 255, 255, 0.75);
      --card-border: rgba(15, 23, 42, 0.1);
      --text: #0f172a;
      --muted: #64748b;
      --accent: #0ea5e9;
      --accent-hover: #0284c7;
      --good: #22c55e;
      --bad: #ef4444;
      --line: rgba(15, 23, 42, 0.1);
      --font-main: 'Outfit', sans-serif;
      --font-mono: 'JetBrains Mono', monospace;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: var(--font-main);
      color: var(--text);
      background: var(--bg);
      background-image: 
        radial-gradient(circle at 15% 50%, rgba(14, 165, 233, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
      background-attachment: fixed;
    }

    .page {
      width: min(1600px, calc(100% - 24px));
      margin: 0 auto;
      padding: 24px 0;
    }

    header {
      margin-bottom: 24px;
      text-align: center;
      animation: fadeInDown 0.6s ease-out;
    }

    @keyframes fadeInDown {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    header h1 {
      margin: 0 0 8px;
      font-size: 2.8rem;
      font-weight: 800;
      background: linear-gradient(135deg, #0284c7, #6d28d9);
      -webkit-background-clip: text;
      -webkit-text-fill-color: var(--muted);
      letter-spacing: -0.5px;
    }

    header p {
      margin: 0;
      color: var(--muted);
      font-size: 1.05rem;
    }

    .layout {
      display: grid;
      grid-template-columns: 320px minmax(0, 1fr) 320px;
      gap: 20px;
      align-items: start;
    }

    .card {
      border-radius: 20px;
      border: 1px solid var(--card-border);
      background: var(--card);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      padding: 20px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .card:hover {
      box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    }

    .card h2 {
      margin: 0 0 16px;
      font-size: 1.15rem;
      font-weight: 600;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      color: var(--accent);
    }

    .compact-grid {
      display: grid;
      gap: 12px;
      margin-bottom: 16px;
    }

    .compact-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 0.95rem;
      font-weight: 400;
    }

    .stepper {
      display: flex;
      align-items: center;
      gap: 6px;
      background: rgba(255, 255, 255, 0.6);
      padding: 4px;
      border-radius: 12px;
      border: 1px solid var(--line);
    }

    .stepper button {
      width: 28px;
      height: 28px;
      border: none;
      border-radius: 8px;
      background: transparent;
      color: var(--text);
      cursor: pointer;
      font-size: 1.2rem;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
    }

    .stepper button:hover { 
      background: var(--accent); 
      color: #fff;
    }

    .stepper span {
      min-width: 24px;
      text-align: center;
      font-weight: 600;
      font-family: var(--font-mono);
    }

    .divider {
      height: 1px;
      background: linear-gradient(90deg, transparent, var(--line), transparent);
      margin: 20px 0;
    }

    .slider-block {
      margin-bottom: 16px;
    }

    input[type="text"] {
      width: 100%;
      padding: 10px 14px;
      border-radius: 10px;
      border: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.6);
      color: var(--text);
      font-size: 0.9rem;
      margin-bottom: 8px;
      font-family: var(--font-main);
      transition: all 0.2s;
    }

    input[type="text"]:focus {
      outline: none;
      border-color: var(--accent);
      background: rgba(56, 189, 248, 0.1);
      box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
    }

    input[type="range"] {
      width: 100%;
      accent-color: var(--accent);
      cursor: pointer;
    }

    .slider-val {
      font-size: 0.85rem;
      color: var(--muted);
      text-align: right;
      margin-bottom: 6px;
      font-family: var(--font-mono);
    }

    .output-card {
      padding: 14px;
      border-radius: 12px;
      margin-bottom: 12px;
      background: rgba(255, 255, 255, 0.6);
      border: 1px solid var(--line);
      transition: all 0.3s ease;
    }

    .output-card.winner { 
      border-color: var(--good); 
      background: rgba(74, 222, 128, 0.1);
      transform: scale(1.02);
    }

    .output-val {
      font-size: 1.25rem;
      font-weight: 800;
      color: var(--text);
      margin-top: 6px;
      font-family: var(--font-mono);
    }
    
    .output-card.winner .output-val {
      color: var(--good);
    }

    .bar {
      height: 6px;
      border-radius: 999px;
      background: rgba(15, 23, 42, 0.05);
      margin-top: 8px;
      overflow: hidden;
    }

    .bar-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--accent), #8b5cf6);
      transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .output-card.winner .bar-fill {
      background: var(--good);
      box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    }

    .result-line {
      margin: 16px 0 0;
      font-size: 0.95rem;
      color: var(--muted);
      line-height: 1.5;
      text-align: center;
    }

    .result-line strong { 
      color: var(--accent); 
      font-weight: 600;
    }

    .btn {
      width: 100%;
      margin-top: 12px;
      padding: 12px;
      border-radius: 10px;
      border: none;
      background: linear-gradient(135deg, var(--accent), #2563eb);
      color: #fff;
      cursor: pointer;
      font-size: 0.95rem;
      font-weight: 600;
      font-family: var(--font-main);
      transition: all 0.2s;
      box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    }

    .btn:hover { 
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    }
    
    .btn:active {
      transform: translateY(0);
    }

    .weight-list {
      max-height: 240px;
      overflow-y: auto;
      margin-top: 12px;
      padding-right: 6px;
    }
    
    .weight-list::-webkit-scrollbar {
      width: 6px;
    }
    .weight-list::-webkit-scrollbar-track {
      background: rgba(0,0,0,0.1);
      border-radius: 4px;
    }
    .weight-list::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.2);
      border-radius: 4px;
    }

    .weight-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto auto;
      gap: 6px;
      align-items: center;
      padding: 8px 10px;
      margin-bottom: 6px;
      border-radius: 10px;
      font-size: 0.85rem;
      background: rgba(255, 255, 255, 0.6);
      border: 1px solid transparent;
      cursor: pointer;
      transition: all 0.2s;
    }
    
    .weight-row:hover {
      background: rgba(15, 23, 42, 0.05);
    }

    .weight-row.selected {
      border-color: var(--accent);
      background: rgba(56, 189, 248, 0.15);
    }

    .weight-row-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: var(--text);
    }

    .weight-row-val {
      font-weight: 600;
      min-width: 36px;
      text-align: center;
      font-family: var(--font-mono);
    }

    .weight-row-mini,
    .bias-row-mini {
      width: 26px;
      height: 26px;
      border: none;
      border-radius: 6px;
      background: rgba(15, 23, 42, 0.05);
      color: var(--text);
      cursor: pointer;
      font-weight: 700;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
    }
    
    .weight-row-mini:hover,
    .bias-row-mini:hover {
      background: var(--accent);
      color: #fff;
    }

    .weight-list-hint {
      font-size: 0.85rem;
      color: var(--muted);
      margin-top: 6px;
      line-height: 1.5;
    }

    .svg-container {
      width: 100%;
      overflow-x: auto;
      border-radius: 16px;
      border: 1px solid var(--card-border);
      background: radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, rgba(241, 245, 249, 0.9) 100%);
      box-shadow: inset 0 0 40px rgba(0,0,0,0.05);
    }
    
    .svg-container::-webkit-scrollbar {
      height: 8px;
    }
    .svg-container::-webkit-scrollbar-track {
      background: transparent;
      border-radius: 0 0 16px 16px;
    }
    .svg-container::-webkit-scrollbar-thumb {
      background: rgba(15,23,42,0.2);
      border-radius: 4px;
    }

    #networkSvg {
      width: 100%;
      min-width: 700px;
      height: min(88vh, 800px);
      display: block;
    }

    .weight-bar {
      margin-top: 16px;
      padding: 16px;
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.6);
      border: 1px solid var(--card-border);
    }

    .weight-bar-title {
      font-size: 0.95rem;
      margin-bottom: 12px;
      color: var(--muted);
      text-align: center;
    }

    .weight-bar-title strong { color: var(--text); font-weight: 600; }

    .weight-controls {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .weight-controls button {
      flex: 1;
      padding: 12px;
      border-radius: 12px;
      border: none;
      font-size: 1.4rem;
      font-weight: 800;
      cursor: pointer;
      transition: all 0.2s;
      color: var(--text);
    }

    #weightInputField {
      flex: 2;
      padding: 12px;
      border-radius: 12px;
      border: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.8);
      color: var(--text);
      font-size: 1.2rem;
      font-weight: 600;
      text-align: center;
      font-family: var(--font-mono);
      transition: all 0.2s;
    }

    #weightInputField:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
    }

    #weightMinus { background: rgba(248, 113, 113, 0.15); border: 1px solid rgba(248, 113, 113, 0.2); color: #991b1b; }
    #weightMinus:hover { background: rgba(248, 113, 113, 0.3); color: #fff; }
    
    #weightPlus { background: rgba(74, 222, 128, 0.15); border: 1px solid rgba(74, 222, 128, 0.2); color: #166534; }
    #weightPlus:hover { background: rgba(74, 222, 128, 0.3); color: #fff; }

    .legend {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 16px;
      margin-top: 16px;
      font-size: 0.85rem;
      color: var(--muted);
    }

    .legend span { display: flex; align-items: center; gap: 8px; }
    .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
    .dot.good { background: var(--good); color: var(--good); }
    .dot.bad { background: var(--bad); color: var(--bad); }
    .dot.neu { background: var(--muted); color: var(--muted); box-shadow: none; border: 1px solid var(--muted); }

    @media (max-width: 1400px) {
      .layout { grid-template-columns: 280px minmax(0, 1fr) 280px; gap: 16px; }
    }

    @media (max-width: 1100px) {
      .layout { grid-template-columns: 1fr; }
      #networkSvg { height: 600px; }
    }

/* Node SVG Overrides for Light Mode */
#networkSvg .node-hid {
  fill: url(#gradHid) !important;
  stroke: #cbd5e1 !important;
}

#networkSvg .node-in {
  fill: url(#gradIn) !important;
  stroke: #0ea5e9 !important;
}

#networkSvg .node-out {
  fill: url(#gradOut) !important;
  stroke: #8b5cf6 !important;
}

#networkSvg .text-hid {
  fill: #0f172a !important; 
  font-family: 'JetBrains Mono', monospace !important;
}

#networkSvg .text-in,
#networkSvg .text-out {
  fill: #ffffff !important;
  font-family: 'Outfit', sans-serif !important;
}

.node-selectable {
  cursor: pointer;
  pointer-events: auto !important;
  transition: stroke-width 0.2s, filter 0.2s;
}

.node-selectable:hover {
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.3)) !important;
}

.node-selected {
  stroke: #1e40af !important;
  stroke-width: 4 !important;
}
