/**
 * Internet Path — dark immersive play UI (StudyTonight brand accents).
 */
:root {
  --bg: #0a0c11;
  --panel: #121624;
  --panel2: #1a1f2e;
  --line: #2a3348;
  --tx: #e8ecf4;
  --tx2: #8b95a8;
  --accent: #4d38b2;
  --accent2: #ffb800;
  --ok: #34d399;
  --bad: #f87171;
  --cyan: #22d3ee;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --display: 'Outfit', var(--font);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font);
  overflow: hidden;
}

.st-strip {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: #0d1018;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.st-strip-left, .st-strip-right { display: flex; align-items: center; gap: 10px; }
.st-strip-logo {
  color: var(--tx);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 800;
  font-size: 14px;
}
.st-strip-logo span { color: var(--accent2); }
.st-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}
.st-strip-sep { width: 1px; height: 16px; background: var(--line); }
.st-strip-label { font-size: 11px; color: var(--tx2); display: flex; align-items: center; gap: 6px; }
.st-live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.st-strip-xp {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(255, 184, 0, 0.08);
  border: 1px solid rgba(255, 184, 0, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
}
.st-strip-back {
  color: var(--tx2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.st-strip-back:hover { color: var(--tx); }

.app {
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  grid-template-rows: auto 1fr;
  height: calc(100% - 44px);
  gap: 0;
}

.challenge-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.challenge-bar .badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent2);
  background: rgba(255, 184, 0, 0.1);
  border: 1px solid rgba(255, 184, 0, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
}
.challenge-bar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 800;
}
.challenge-bar .goal { font-size: 12px; color: var(--tx2); flex: 1; min-width: 180px; }
.challenge-bar .eli5 {
  font-size: 11px;
  color: #c4b5fd;
  background: rgba(77, 56, 178, 0.2);
  border: 1px solid rgba(77, 56, 178, 0.35);
  padding: 4px 8px;
  border-radius: 8px;
  max-width: 360px;
}
.chapter-pill {
  font-size: 10px;
  font-weight: 700;
  color: #a5f3fc;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
}
.case-file {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.case-file ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--tx2);
  line-height: 1.5;
}
.case-file li { margin-bottom: 4px; }
.inspector {
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: #0d111a;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: #cbd5e1;
  white-space: pre-wrap;
  max-height: 100px;
  overflow: auto;
}
.quiz-block {
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.quiz-q {
  margin: 0 0 10px !important;
  color: var(--tx) !important;
  font-weight: 700;
  font-size: 13px !important;
}
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quiz-choices button {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--tx);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}
.quiz-choices button:hover { border-color: var(--accent); }
.quiz-choices button.correct {
  border-color: var(--ok);
  color: var(--ok);
}
.quiz-choices button.wrong {
  border-color: var(--bad);
  color: var(--bad);
}
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--panel2);
  padding: 3px;
  border-radius: 10px;
}
.mode-tabs button {
  border: 0;
  background: transparent;
  color: var(--tx2);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.mode-tabs button.active {
  background: var(--accent);
  color: #fff;
}
.mode-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px;
  overflow-y: auto;
}
.sidebar h2 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tx2);
  font-family: var(--display);
}
.device-list { display: flex; flex-direction: column; gap: 6px; }
.device-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
}
.device-chip:active { cursor: grabbing; }
.device-chip .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: rgba(255,255,255,0.04);
}
.hint-line {
  margin-top: 14px;
  font-size: 11px;
  color: var(--tx2);
  line-height: 1.45;
}

.workspace-wrap {
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, rgba(77, 56, 178, 0.12), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(34, 211, 238, 0.06), transparent 35%),
    var(--bg);
  overflow: hidden;
}
#board {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.grid-bg {
  fill: transparent;
}

.right-rail {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.rail-actions button, .port-select {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--tx);
  font-size: 11px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.rail-actions button.primary {
  background: var(--ok);
  color: #042f1e;
  border-color: transparent;
}
.rail-actions button.accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.rail-actions button.warn {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--bad);
}
.rail-panel {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.rail-panel h3 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tx2);
  font-family: var(--display);
}
.status-pill {
  display: inline-block;
  font-weight: 800;
  font-family: ui-monospace, monospace;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel2);
}
.status-pill.ok { color: var(--ok); }
.status-pill.bad { color: var(--bad); }
.body-preview {
  margin-top: 6px;
  padding: 8px;
  border-radius: 8px;
  background: #0d111a;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #a5f3fc;
  white-space: pre-wrap;
  max-height: 80px;
  overflow: auto;
}
.latency { color: var(--accent2); font-weight: 700; font-size: 11px; margin-top: 4px; }
.log-box {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
}
.log-box .err { color: var(--bad); }
.glossary {
  max-height: 160px;
  overflow: auto;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}
.glossary details { font-size: 11px; color: var(--tx2); margin-top: 6px; }
.glossary summary { cursor: pointer; color: var(--tx); font-weight: 600; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(18, 22, 36, 0.95);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--bad);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  z-index: 5;
  display: none;
}
.toast.show { display: block; }
.toast.ok {
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--ok);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.modal h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 20px;
}
.modal p { margin: 0 0 16px; color: var(--tx2); font-size: 13px; line-height: 1.5; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; }
.modal button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.modal .next {
  background: var(--accent);
  color: #fff;
}

.node-label {
  font-size: 10px;
  font-weight: 700;
  fill: var(--tx);
  pointer-events: none;
}
.port-dot {
  cursor: crosshair;
}
.edge-line {
  stroke: var(--cyan);
  stroke-width: 2.5;
  fill: none;
  opacity: 0.85;
}
.edge-line.broken {
  stroke: var(--bad);
  stroke-dasharray: 6 4;
}
.packet {
  fill: var(--accent2);
  filter: drop-shadow(0 0 6px rgba(255, 184, 0, 0.8));
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  .sidebar { display: flex; flex-wrap: wrap; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); max-height: 120px; }
  .device-list { flex-direction: row; flex-wrap: wrap; }
  .right-rail { border-left: 0; border-top: 1px solid var(--line); max-height: 220px; }
}
