#osi-layers {
  --osi-muted: #62635e;
  --osi-line: #d5d5c9;
  --osi-surface: #f5f5ed;
  --osi-data-bg: #e8efdf;
  --osi-data-ink: #3d5929;
  --osi-tcp-bg: #e3edf3;
  --osi-tcp-ink: #315b75;
  --osi-ip-bg: #efe7f5;
  --osi-ip-ink: #705084;
  --osi-ethernet-bg: #f6eadb;
  --osi-ethernet-ink: #805322;
  --osi-cell-font-size: 0.8rem;
  --osi-http-height: 48px;
  --osi-tcp-field-height: 28px;
  --osi-ip-field-height: 28px;
  --osi-ethernet-field-height: 28px;
  --osi-fcs-height: 40px;
  width: 90%;
  max-width: 960px;
  margin: 2rem 0;
  color: var(--page-text);
  font: 0.9rem/1.5 system-ui, sans-serif;
  overflow-wrap: normal;
}

html[data-theme="dark"] #osi-layers {
  --osi-muted: #a7a79d;
  --osi-line: #41433b;
  --osi-surface: #20211d;
  --osi-data-bg: #263320;
  --osi-data-ink: #bdd4a7;
  --osi-tcp-bg: #20313c;
  --osi-tcp-ink: #aacfe6;
  --osi-ip-bg: #31283c;
  --osi-ip-ink: #d0b6e3;
  --osi-ethernet-bg: #392d20;
  --osi-ethernet-ink: #e6c093;
}

#osi-layers * { box-sizing: border-box; }
#osi-layers table { width: 100%; table-layout: fixed; border-collapse: collapse; }
#osi-layers caption { text-align: left; font-size: 1.1rem; font-weight: 600; }
#osi-layers th, #osi-layers td { width: 20%; padding: 0; border: 1px solid var(--osi-line); vertical-align: middle; text-align: center; }
#osi-layers th > strong { display: block; font-size: 1.1rem; }
#osi-layers th > span { display: block; color: var(--osi-muted); font-size: 0.8rem; font-weight: 400; }
/* Row spans make each payload share both edges with the full packet to its left. */
#osi-layers td { font-size: var(--osi-cell-font-size); }
#osi-layers td > strong { font-weight: 600; }
#osi-layers .osi-data { height: var(--osi-http-height); background: var(--osi-data-bg); color: var(--osi-data-ink); }
#osi-layers .osi-message { white-space: pre; }
#osi-layers .osi-field { overflow-wrap: anywhere; }
#osi-layers .osi-field > strong { margin-right: 0.3rem; }
#osi-layers .osi-tcp-field { height: var(--osi-tcp-field-height); background: var(--osi-tcp-bg); color: var(--osi-tcp-ink); }
#osi-layers .osi-ip-field { height: var(--osi-ip-field-height); background: var(--osi-ip-bg); color: var(--osi-ip-ink); }
#osi-layers .osi-ethernet-field { height: var(--osi-ethernet-field-height); background: var(--osi-ethernet-bg); color: var(--osi-ethernet-ink); }
#osi-layers .osi-payload { background: var(--osi-surface); color: var(--osi-muted); }
#osi-layers .osi-fcs { height: var(--osi-fcs-height); background: var(--osi-ethernet-bg); color: var(--osi-ethernet-ink); }
#osi-layers .osi-fcs > strong, #osi-layers .osi-fcs > span { display: block; }
#osi-layers .osi-physical > span { display: block; font-size: 1.5rem; line-height: 2; }

@media (max-width: 1024px) {
  #osi-layers { --osi-cell-font-size: clamp(0.6rem, 1.9vw, 0.8rem); --osi-tcp-field-height: 42px; --osi-ip-field-height: 46px; --osi-ethernet-field-height: 46px; }
  #osi-layers th > strong { font-size: clamp(0.75rem, 2.6vw, 1.1rem); }
  #osi-layers th > span { font-size: var(--osi-cell-font-size); }
  #osi-layers .osi-field > strong { display: block; margin: 0; }
}

@media (max-width: 760px) {
  #osi-layers { width: 100%; }
}

@media print {
  #osi-layers { width: 100%; max-width: none; break-inside: avoid; }
}
