:root {
  color-scheme: light;
  --ink: #111;
  --muted: #475975;
  --line: #dbe4f1;
  --blue: #007bff;
  --blue-dark: #0056b3;
  --soft-blue: #e9efff;
  --green: #126a57;
  --red: #a3323d;
  --mono: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-family: Arial, sans-serif;
  line-height: 1.2;
  background: #f0f0f0;
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 18rem; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button:focus-visible, summary:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #3767e1;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: fixed;
  inset: 0 0 auto;
  padding: 10px 0;
  z-index: 900;
  background: var(--blue);
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 2px -2px gray;
}

.site-header h1 { margin: 0; font-size: 2em; }

.site-footer {
  position: fixed;
  inset: auto 0 0;
  height: 20px;
  z-index: 900;
  background: var(--blue);
  pointer-events: none;
}

.course-navigation {
  display: flex;
  align-items: center;
  gap: .45rem;
  max-width: 1040px;
  margin: 60px auto 0;
  padding: 8px 20px 0;
}

.menu-button, .nav-button {
  padding: 10px 20px;
  border-radius: 5px;
  background: var(--blue);
  color: white;
  font-size: 16px;
  text-align: center;
  white-space: nowrap;
}

.menu-button {
  margin-right: auto;
  background: #009fff;
}

.workspace {
  max-width: 1040px;
  margin: 60px auto 20px;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 10px rgb(0 0 0 / 10%);
}

.course-navigation:not([hidden]) + .workspace { margin-top: 10px; }
.workspace > section > h2 { margin-top: 0; color: var(--blue); }
.task-list { margin-left: 5px; padding-left: 0; list-style: square; }
.task-list li { margin-bottom: 5px; padding-left: 2px; }

@media (min-width: 80rem) {
  .course-navigation { margin: 0; padding: 0; }
  .course-navigation:not([hidden]) + .workspace { margin-top: 60px; }
  .menu-button, .nav-button { position: fixed; transform: translateY(-50%); }
  .menu-button { top: 30px; z-index: 1000; }
  .nav-button { top: 15%; z-index: 901; }
  .left-button { left: 10px; }
  .right-button { right: 10px; }
}

.worksheet {
  width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: #fff;
}

.worksheet summary { cursor: pointer; padding: .62rem .85rem; font-weight: 640; }
.worksheet ol { margin: 0; padding: 0 1rem .85rem 2.1rem; line-height: 1.45; }
.worksheet li + li { margin-top: .42rem; }
code { font-family: var(--mono); font-size: 120%; font-weight: bold; overflow-wrap: anywhere; }

.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 1rem;
}

.panel {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .85rem;
  box-shadow: 0 3px 12px #13274b09;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem 1rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 { margin: 0; font-size: 1.09rem; line-height: 1.3; }
.count { color: var(--muted); font-size: .875rem; text-align: right; }
.tools { display: flex; flex-wrap: wrap; gap: .55rem; padding: .85rem 1.1rem; }
.button, .text-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  min-height: 2.45rem;
  padding: .46rem .8rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  font-size: .91rem;
  font-weight: 640;
  line-height: 1.25;
}

.button-primary { background: #0069d9; color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-outline { background: #fff; color: var(--ink); border-color: #c9d5e8; }
.button-outline:hover:not(:disabled), .button-outline[aria-pressed="true"] {
  color: var(--blue-dark);
  border-color: #8da7ee;
  background: var(--soft-blue);
}

.button:disabled, .text-button:disabled { opacity: .52; }
#add-device:not(:disabled) { cursor: grab; touch-action: none; user-select: none; }
#add-device.is-dragging:not(:disabled) { cursor: grabbing; }
.text-button { background: transparent; color: var(--muted); padding-inline: .4rem; }
.text-button:hover:not(:disabled) { color: var(--blue-dark); text-decoration: underline; }
.empty-node-icon { position: relative; display: inline-block; color: currentColor; }
.empty-node-icon::before, .empty-node-icon::after {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  width: .75rem;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.empty-node-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.wire-icon { display: inline-block; width: 1.1rem; height: .125rem; background: currentColor; position: relative; }
.wire-icon::before, .wire-icon::after {
  position: absolute;
  content: "";
  width: .30rem;
  height: .32rem;
  top: -.10rem;
  border-radius: 1px;
  background: currentColor;
}

.wire-icon::after { right: 0; }

.topology-panel { display: flex; flex-direction: column; }
.board {
  --left-end: 25%;
  --right-end: 75%;
  position: relative;
  min-height: 13.3rem;
  flex: 1;
  margin-inline: 1.1rem;
  border: 1px solid #d4e0f1;
  border-radius: .64rem;
  background: radial-gradient(circle, #b8c9e4 1px, transparent 1.4px) 0 0 / 1.125rem 1.125rem,
    #edf3fc;
  isolation: isolate;
}

.board.is-drop-target { outline: 2px dashed var(--blue); outline-offset: -3px; }
.board-status { min-height: 3.2rem; margin: 0; padding: .65rem 1.1rem .8rem; color: var(--muted); line-height: 1.4; font-size: .9rem; }
.board[data-connected="true"] + .board-status { color: var(--green); }
.node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(41%, 10.4rem);
  min-height: 6.7rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .28rem;
  padding: .62rem .3rem;
  border: 1px dashed #8a9db9;
  border-radius: .68rem;
  background: #f7faff;
  color: var(--muted);
  z-index: 2;
}

.node-left { left: var(--left-end); }
.node-right { left: var(--right-end); }
.node:hover:not(:disabled) { border-color: var(--blue); background: #fff; }
.node.is-device { border: 1px solid #adbfda; background: #fff; color: var(--ink); box-shadow: 0 4px 11px #20416d15; }
.node.is-device.is-selected { border-color: var(--blue); box-shadow: 0 0 0 2px #d5e0ff, 0 4px 10px #20416d18; }
.node.is-device.is-wire-start { border-color: var(--green); box-shadow: 0 0 0 2px #bfe8dd; }
.node-name { font-size: .9rem; font-weight: 650; text-align: center; }
.node-address { font-family: var(--mono); font-size: .80rem; line-height: 1.3; color: var(--muted); }
.empty-node-icon { width: 1.65rem; height: 1.65rem; border: 1px solid #bac9e0; border-radius: 50%; }
.device-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 2.24em;
  height: 1.66em;
  forced-color-adjust: none;
}

.device-icon::before, .device-icon::after {
  content: "";
  position: absolute;
}

.device-icon[data-icon="pc"]::before {
  inset: .05em .05em .39em;
  border: .13em solid #315994;
  border-radius: .23em;
  background: #d8e7ff;
  box-shadow: inset 0 -.18em #b5cdf3;
}
.device-icon[data-icon="pc"]::after {
  inset: auto .66em .04em;
  height: .42em;
  background: #315994;
  clip-path: polygon(38% 0, 62% 0, 62% 64%, 100% 64%, 100% 100%, 0 100%, 0 64%, 38% 64%);
}

.device-icon[data-icon="server"] { --rack-edge: #415976; --rack-fill: #e2eaf3; --rack-led: #087960; }
.device-icon[data-icon="dns"] { --rack-edge: #644e90; --rack-fill: #eee7ff; --rack-led: #7652a9; }
.device-icon[data-icon="server"]::before, .device-icon[data-icon="dns"]::before {
  inset: .02em .50em;
  border: .12em solid var(--rack-edge);
  border-radius: .20em;
  background:
    radial-gradient(circle, var(--rack-led) 46%, transparent 60%) .12em .14em / .25em .25em no-repeat,
    radial-gradient(circle, var(--rack-led) 46%, transparent 60%) .12em 1em / .25em .25em no-repeat,
    linear-gradient(var(--rack-edge), var(--rack-edge)) center / 100% .1em no-repeat,
    var(--rack-fill);
}
.device-icon[data-icon="dns"]::after {
  right: .13em;
  bottom: -.04em;
  width: 1em;
  height: 1em;
  border: .11em solid var(--rack-edge);
  border-radius: 50%;
  background:
    linear-gradient(transparent 43%, var(--rack-edge) 43% 57%, transparent 57%),
    radial-gradient(ellipse .24em .46em at center, transparent 57%, var(--rack-edge) 65% 93%, transparent 97%),
    #faf5ff;
  box-shadow: 0 0 0 .08em #fff;
}

.device-icon[data-icon="switch"]::before {
  inset: .36em 0 .28em;
  border: .12em solid #216756;
  border-radius: .22em;
  background: #c9e9e1;
  box-shadow: inset 0 -.18em #a5d3c6;
}
.device-icon[data-icon="switch"]::after {
  left: .31em;
  top: .67em;
  width: .27em;
  height: .30em;
  border-radius: .035em;
  color: #216756;
  background: currentColor;
  box-shadow: .45em 0, .9em 0, 1.35em 0;
}

.device-icon[data-icon="router"] {
  width: 2.14em;
  height: 1.38em;
  margin-block: .14em;
  border: .12em solid #81551b;
  border-radius: 50%;
  background: #f9e4b8;
  box-shadow: inset 0 -.15em #e8c991;
}
.device-icon[data-icon="router"]::before, .device-icon[data-icon="router"]::after {
  inset-inline: .31em;
  height: .33em;
  background: #81551b;
  clip-path: polygon(0 35%, 72% 35%, 72% 0, 100% 50%, 72% 100%, 72% 65%, 0 65%);
}
.device-icon[data-icon="router"]::before { top: .20em; }
.device-icon[data-icon="router"]::after { bottom: .17em; transform: rotate(180deg); }

.computer-icon { margin: .14rem 0 .28rem; }
.tools .device-icon, .course-device .device-icon, .course-router-title .device-icon { font-size: .81rem; }
.ethernet-port {
  position: absolute;
  top: 50%;
  width: .56rem;
  height: .56rem;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translateY(-50%);
  background: #889ebe;
  box-shadow: 0 0 0 1px #97abcb;
}

.node-left .ethernet-port { right: -.28rem; }
.node-right .ethernet-port { left: -.28rem; }
[data-connected="true"] .ethernet-port { background: #238a75; box-shadow: 0 0 0 1px #238a75; }
.cable {
  position: absolute;
  top: calc(50% - 1.5px);
  left: var(--left-end);
  right: calc(100% - var(--right-end));
  height: 3px;
  border-radius: 3px;
  background: #59729c;
}

.cable.is-highlighted { background: #238a75; box-shadow: 0 0 0 4px #4ebca830; }
.signal {
  opacity: 0;
  position: absolute;
  z-index: 3;
  top: 50%;
  width: .61rem;
  height: .61rem;
  border-radius: 50%;
  background: #207a63;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.device-controls { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.address-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: .55rem .65rem; }
.address-fields label { font-size: .91rem; color: var(--muted); }
.inspector form, .ping form { padding: .85rem 1.1rem; }
.panel-placeholder { margin: 0; padding: 1rem 1.1rem; color: var(--muted); font-size: .93rem; }
.inspector input, .ping-command {
  width: 100%;
  min-width: 0;
  min-height: 2.43rem;
  border: 1px solid #c9d5e8;
  border-radius: .46rem;
  background: #fbfdff;
}

.inspector input { padding: .46rem .6rem; font-family: var(--mono); color: var(--ink); }
.inspector input:focus, .ping-command:focus-within { outline: 2px solid #3969e6; outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--red); }
input::placeholder { color: #526784; opacity: 1; }
.settings-actions, .ping-controls { display: flex; flex-wrap: wrap; gap: .4rem .6rem; margin-top: .7rem; }
.form-message, .ping-output { color: var(--muted); line-height: 1.45; font-size: .875rem; margin: .55rem 0 0; }
.form-message[data-kind="success"], .ping-output[data-kind="success"] { color: var(--green); }
.form-message[data-kind="error"], .ping-output[data-kind="error"] { color: var(--red); }
.ping-controls { flex-wrap: nowrap; margin-top: 0; }
.ping-command { display: flex; align-items: center; font-family: var(--mono); }
.ping-command span { align-self: stretch; display: inline-grid; place-items: center; padding: 0 .55rem; color: var(--blue-dark); background: #eaf0fd; border-radius: .43rem 0 0 .43rem; }
.ping-command input { width: 100%; min-width: 0; padding: .43rem .53rem; background: none; border: 0; color: var(--ink); outline: 0; }
.ping-output { min-height: 1.4rem; }

.traffic { margin-top: 1rem; }
.traffic-header, .traffic-heading, .traffic-actions { display: flex; align-items: center; flex-wrap: wrap; }
.traffic-heading, .traffic-actions { gap: .45rem .75rem; }
.filter-group { display: inline-flex; background: #edf2fb; padding: .18rem; border-radius: .48rem; }
.filter-group button {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: .33rem;
  padding: .36rem .62rem;
  font-size: .875rem;
  font-weight: 640;
}

.filter-group button:hover { color: var(--blue-dark); }
.filter-group [aria-pressed="true"] { color: var(--blue-dark); background: #fff; border-color: #d1def8; box-shadow: 0 1px 2px #24436b12; }
.traffic-body { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.trace-scroll { overflow: auto; min-height: 11.5rem; max-height: 18rem; }
.packet-table { width: 100%; border-collapse: collapse; font-size: .885rem; line-height: 1.35; }
.packet-table thead { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f3f6fc; }
.packet-table th, .packet-table td { border-bottom: 1px solid #e4ebf5; padding: .51rem .57rem; white-space: nowrap; text-align: left; }
.packet-table th:first-child, .packet-table td:first-child { padding-left: 1.05rem; }
.packet-table td:nth-child(3), .packet-table td:nth-child(4) { font-family: var(--mono); }
.packet-table tbody tr[data-packet] { cursor: pointer; }
.packet-table tbody tr[data-packet]:hover { background: #f3f6ff; }
.packet-table tbody tr.is-inspected { background: #eaf0ff; }
.packet-table .empty-trace { padding: 1.1rem; white-space: normal; color: var(--muted); border-bottom: 0; }
.packet-name {
  display: inline-block;
  padding: .12rem .04rem;
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  text-align: left;
  font-weight: 640;
}

.packet-name:hover { text-decoration: underline; }
.protocol { display: inline-block; padding: .17rem .43rem; font-family: var(--mono); border-radius: .33rem; font-size: .81rem; font-weight: 640; }
.protocol-arp { color: #1747a0; background: #e6eeff; }
.protocol-icmp { color: #125945; background: #e0f4ec; }
.protocol-tcp { color: #5c3690; background: #f0eaff; }
.protocol-text, .protocol-http { color: #164c6a; background: #e4f3fd; }
.protocol-dns { color: #74511c; background: #fff3d7; }
.packet-details { padding: .88rem 1.05rem 1rem; border-left: 1px solid var(--line); }
.packet-details h4 { margin: 0; font-size: .96rem; }
.packet-details p { margin-top: .4rem; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.packet-layer { margin-top: .65rem; padding-top: .5rem; border-top: 1px solid #e4ebf5; }
.packet-layer h5 { margin: 0; font-size: .875rem; color: var(--ink); }
.packet-layer dl { margin: .35rem 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .2rem .65rem; font-size: .875rem; }
.packet-layer dt { color: var(--muted); }
.packet-layer dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

.course-board { flex: 0 0 auto; min-height: 26rem; margin-top: .35rem; }
.course-board[data-task-board="2"] { min-height: 18rem; }
.course-board[data-task-board="5"] { min-height: 27rem; }
.course-lines { position: absolute; inset: 0; pointer-events: none; }
.course-line {
  position: absolute;
  height: 3px;
  border-radius: 3px;
  background: #59729c;
  transform-origin: left center;
}
.course-line.is-highlighted { background: #238a75; box-shadow: 0 0 0 3px #4ebca830; }
.course-slot {
  position: absolute;
  z-index: 1;
  width: min(27%, 8rem);
  transform: translate(-50%, -50%);
}
.course-switch { width: min(20%, 7.4rem); }
.course-board[data-task-board="2"] .course-switch { width: min(26%, 8rem); }
.course-device {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .20rem;
  width: 100%;
  min-height: 3.35rem;
  padding: .28rem .19rem;
  border: 1px solid #adbfda;
  border-radius: .58rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 9px #20416d18;
  overflow-wrap: anywhere;
}
.course-device[data-kind="empty"] {
  border-style: dashed;
  background: #f7faff;
  color: var(--muted);
  box-shadow: none;
}
.course-device[data-kind="empty"] .device-icon { opacity: .73; }
.course-device[data-kind="server"], .course-device[data-kind="dns"] { background: #f5faff; }
.course-device[data-kind="switch"] { background: #f3f6ff; }
.course-device:hover:not(:disabled), .course-device[aria-pressed="true"] {
  border-color: var(--blue);
  background: #f4f8ff;
}
.course-device[aria-pressed="true"] { box-shadow: 0 0 0 2px #d5e0ff; }
.course-device.is-wire-start { border-color: var(--green); box-shadow: 0 0 0 2px #bfe8dd; }
.course-router {
  display: grid;
  grid-template-columns: repeat(var(--router-ports), minmax(0, 1fr));
  gap: .26rem;
  width: min(52%, 10.6rem);
  padding: .36rem;
  background: #f3f6ff;
  border: 1px solid #adbfda;
  border-radius: .58rem;
}
.course-router-title {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}
.course-router .course-device { min-height: 1.9rem; padding-inline: .16rem; }
.course-device .node-name { font-size: .82rem; }
.course-device .node-address { font-size: .73rem; }
.course-cable-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 0 1.1rem .95rem;
}
.course-cable-tools select { flex: 1 1 13rem; width: 0; }
.course-cable-tools select, .course-controls select, .course-controls textarea {
  min-width: 0;
  max-width: 100%;
  padding: .46rem .6rem;
  border: 1px solid #c9d5e8;
  border-radius: .45rem;
  background: #fcfdff;
  color: var(--ink);
}
.course-board + .board-status[data-kind="error"] { color: var(--red); }
.course-board + .board-status[data-kind="success"] { color: var(--green); }
.course-panel-body { padding: .85rem 1.1rem; }
.course-panel-body form { padding: 0; }
.course-panel-body form + form, .course-panel-body > p + form { margin-top: .75rem; }
.course-panel-body form > label, #course-editor > label { font-size: .91rem; color: var(--muted); }
.check-line { display: flex; align-items: center; gap: .4rem; margin-top: .6rem; font-size: .91rem; }
.check-line input { width: auto; }
.course-input-row { display: flex; gap: .4rem; margin-top: .25rem; }
.course-input-row input { flex: 1; min-width: 0; }
.terminal-output {
  max-height: 12rem;
  overflow: auto;
  padding: .58rem;
  border-radius: .44rem;
  background: #edf3fc;
  font: .78rem/1.45 var(--mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
#course-editor select { width: 100%; margin: .23rem 0 .54rem; }
#course-editor textarea { width: 100%; resize: vertical; font: .85rem/1.4 var(--mono); }
.course-preview {
  margin-top: .7rem;
  padding: .7rem;
  max-height: 18rem;
  overflow: auto;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: .45rem;
}
.course-preview h1 { font-size: 1.3rem; }
.course-preview h2 { font-size: 1.12rem; }
.course-preview > :first-child { margin-top: 0; }
.course-preview > :last-child { margin-bottom: 0; }
.course-preview a { text-decoration: underline; }
.course-table-wrap { overflow: auto; }
.course-table { width: 100%; border-collapse: collapse; font-size: .83rem; text-align: left; overflow-wrap: anywhere; }
.course-table th, .course-table td { padding: .38rem .3rem; border-bottom: 1px solid var(--line); }
.course-table td { font-family: var(--mono); }

@media (max-width: 54rem) {
  .lab-layout { grid-template-columns: minmax(0, 1fr); }
  .device-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .board:not(.course-board) { min-height: 12rem; }
  .traffic-body { grid-template-columns: minmax(0, 1fr); }
  .trace-scroll { min-height: 8rem; }
  .packet-details { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 39rem) {
  .workspace { padding: 10px; }
  .course-navigation { padding-inline: 10px; }
  .menu-button, .nav-button { padding-inline: .55rem; }
  .device-controls { grid-template-columns: minmax(0, 1fr); }
  .panel-header, .tools, .inspector form, .ping form { padding-inline: .78rem; }
  .board { margin-inline: .78rem; }
  .board-status { padding-inline: .78rem; }
  .packet-table th:first-child, .packet-table td:first-child { padding-left: .78rem; }
  .packet-details { padding-inline: .78rem; }
  .course-cable-tools, .course-panel-body { padding-inline: .78rem; }
}

@media (max-width: 24rem) {
  .course-board:not([data-task-board="2"]) { min-height: 29rem; }
  .course-device .device-icon { font-size: .74rem; }
  .course-device .node-name { font-size: .78rem; }
  .course-device .node-address { font: .69rem/1.3 Arial, sans-serif; font-variant-numeric: tabular-nums; }
}
