/* Adapter Explorer
   paper #F5F7FA  panel #FFFFFF  ink #172033  muted #5A6478  line #DFE4EC
   kinds: connect/security teal #0B7A75, request amber #C8731E, response violet #6B57C9, inside CPI blue #2F64B0, error red #C0392B */
:root {
  --paper: #F5F7FA; --panel: #FFFFFF; --ink: #172033; --muted: #5A6478; --faint: #8A93A6; --line: #DFE4EC; --soft: #EEF2F7;
  --teal: #0B7A75; --amber: #C8731E; --violet: #6B57C9; --blue: #2F64B0; --red: #C0392B; --grey: #7A8396;
  --sans: 'IBM Plex Sans', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 400 15px/1.55 var(--sans); color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 6px; z-index: 99; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
kbd { font: 500 11px/1 var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; color: var(--muted); background: #fff; }

/* header */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 20px; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand small { font-size: 12px; color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; width: 300px; height: 38px; padding: 0 8px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11,122,117,.15); }
.pick { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 380px; gap: 16px; padding: 16px 20px 24px; align-items: start; }
.side, .info { position: sticky; top: 76px; max-height: calc(100vh - 92px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.side-head h2 { margin: 0; font-size: 15px; }
.side-close { display: none; }
.groups { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 16px 10px; border-bottom: 1px solid var(--line); }
.groups button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.groups button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.groups button span { opacity: .7; margin-left: 3px; }
.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.list a { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink); }
.list a:hover { background: var(--soft); }
.list a[aria-current="page"] { background: #E6F3F2; box-shadow: inset 3px 0 0 var(--teal); }
.list .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font: 600 11px/1 var(--mono); color: #fff; }
.list b { display: block; font-weight: 600; font-size: 14.5px; }
.list small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.list .empty { padding: 20px 10px; color: var(--muted); }
.side-note { margin: 0; padding: 10px 16px 14px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); }

/* main */
.main { min-width: 0; display: flex; flex-direction: column; gap: 14px; outline: none; }
.lesson-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0; font-size: 13px; color: var(--teal); font-weight: 600; }
.lesson-head h1 { margin: 2px 0 2px; font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.tagline { margin: 0; color: var(--muted); max-width: 60ch; }
.views { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; flex: none; }
.views button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
.views button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(23,32,51,.12); }

.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.scenario { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); background: #FAFBFD; }
.scenario b { color: var(--ink); }
.canvas { position: relative; background:
  radial-gradient(circle, #E3E8F0 1px, transparent 1.2px) 0 0 / 18px 18px; }
.canvas svg { display: block; width: 100%; height: auto; }
.say { min-height: 76px; padding: 14px 16px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.say .n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 12px/1 var(--mono); }
.say p { margin: 0; }
.say .t { font-weight: 600; }
.say .x { color: var(--muted); }

/* svg pieces */
.node rect.box { fill: #fff; stroke: var(--line); stroke-width: 1.5; transition: stroke .2s, fill .2s; }
.node.on rect.box { stroke: var(--teal); stroke-width: 2.5; fill: #F3FAF9; }
.node text.l { font: 600 16px var(--sans); fill: var(--ink); }
.node text.s { font: 400 13px var(--sans); fill: var(--muted); }
.node .badge { font: 600 11.5px var(--mono); fill: #fff; }
.wire { stroke: #C9D1DD; stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; }
.wire.on { stroke: var(--teal); stroke-dasharray: none; }
.tag-t { font: 500 12.5px var(--mono); fill: var(--faint); }
.lbl-big { font: 600 15px var(--sans); fill: var(--ink); }
.pkt rect { rx: 7; }
.pkt text { font: 600 13px var(--mono); fill: #fff; }
.pulse { fill: none; stroke-width: 2; }
.lifeline { stroke: #C9D1DD; stroke-width: 1.5; stroke-dasharray: 4 5; }
.seq-arrow { stroke-width: 2; fill: none; }
.seq-lbl { font: 500 12px var(--sans); fill: var(--ink); }
.seq-num { font: 600 10px var(--mono); fill: #fff; }
.seq-row.future { opacity: .14; }
.seq-row.cur .seq-lbl { font-weight: 700; }

/* controls */
.controls { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.c-btn, .c-play { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.c-btn { width: 40px; }
.c-btn:hover { background: var(--soft); }
.c-play { padding: 0 16px 0 12px; background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; min-width: 96px; }
.c-play:hover { background: #26324B; }
.controls svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.c-play svg { fill: currentColor; }
.c-play .i-pause { display: none; }
.playing .c-play .i-play { display: none; }
.playing .c-play .i-pause { display: block; fill: none; stroke-width: 3; }
.progress { flex: 1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 40px; }
.bar { height: 100%; width: 0; background: var(--teal); transition: width .3s; }
.count { font: 500 13px var(--mono); color: var(--muted); min-width: 52px; text-align: right; }
.speed select { height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 8px; }

/* message table */
.flowtable { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ft-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 8px; flex-wrap: wrap; }
.ft-head h2 { margin: 0; font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ft-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 6px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--soft); vertical-align: top; }
td.m { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.w { font-family: var(--mono); font-size: 12.5px; word-break: break-word; min-width: 220px; }
.ft { display: none; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.r { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #FAFBFD; }
tbody tr.future { opacity: .38; }
tbody tr.cur { background: #EEF7F6; }
tbody tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 600 11px/1 var(--mono); }

/* right panel */
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; flex: none; }
.tabs button { border: 0; background: none; padding: 12px 10px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--teal); }
.panel { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.panel h2 { font-size: 18px; margin: 0 0 4px; line-height: 1.25; }
.panel h3 { font-size: 13.5px; margin: 20px 0 8px; color: var(--ink); }
.panel p { margin: 0 0 10px; }
.kind { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-bottom: 8px; }
.raw { font: 400 12.3px/1.6 var(--mono); background: #F7F8FB; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: pre; margin: 0 0 4px; color: #2A3550; }
.raw mark { background: #FFF1D6; color: inherit; border-radius: 3px; padding: 0 2px; }
.fields { margin: 0; padding: 0; list-style: none; }
.fields li { padding: 8px 0; border-bottom: 1px solid var(--soft); }
.fields code { font: 500 12.5px var(--mono); background: var(--soft); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
.fields .v { font: 400 12.5px var(--mono); color: var(--muted); word-break: break-all; }
.fields p { margin: 3px 0 0; font-size: 13.5px; }
.facts { width: 100%; font-size: 13.5px; }
.facts th { width: 38%; padding: 7px 10px 7px 0; color: var(--muted); font-weight: 500; font-size: 13px; vertical-align: top; white-space: normal; border-bottom: 1px solid var(--soft); }
.facts td { padding: 7px 0; border-bottom: 1px solid var(--soft); }
.errs { list-style: none; margin: 0; padding: 0; }
.errs li { border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; }
.errs code { font: 600 12.3px var(--mono); color: var(--red); word-break: break-word; }
.errs p { margin: 4px 0 0; font-size: 13.5px; }
.errs .fix { color: var(--teal); }
.help-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.scrim { position: fixed; inset: 0; background: rgba(23,32,51,.35); z-index: 40; }

/* tablet: info panel moves under the lesson */
@media (max-width: 1240px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .info { grid-column: 2; position: static; max-height: none; }
  .panel { overflow: visible; }
}

/* phones */
@media (max-width: 820px) {
  body { font-size: 15px; }
  .top { height: 56px; padding: 0 12px; gap: 10px; }
  .brand small, .search { display: none; }
  .brand strong { font-size: 16px; }
  .pick { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; max-width: 55vw; }
  .pick-k { font-size: 12px; color: var(--muted); }
  .pick-v { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .layout { display: block; padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .main { gap: 12px; }
  .side { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; top: auto; max-height: 82vh; border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .25s ease; visibility: hidden; }
  .side.open { transform: none; visibility: visible; }
  .side-close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: var(--soft); border-radius: 50%; font-size: 22px; cursor: pointer; }
  .side-head { padding: 12px 14px 4px; }
  .side-head h2 { font-size: 17px; }
  .lesson-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .lesson-head h1 { font-size: 25px; }
  .views { align-self: flex-start; }
  .canvas { min-height: 0; }
  .say { min-height: 0; }
  .controls { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; box-shadow: 0 10px 30px -10px rgba(23,32,51,.35); padding: 8px; }
  .speed, .c-btn#bRestart { display: none; }
  .c-play { min-width: 0; }
  .count { min-width: 0; }
  th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4), th:nth-child(6), td:nth-child(6) { display: none; }
  td.w { min-width: 0; }
  .ft { display: block; margin-bottom: 2px; }
  .canvas svg { max-width: 420px; margin: 0 auto; }
  .info { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* operation and authentication pickers */
.pickers { margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; display: grid; gap: 8px; }
.optrow { display: grid; grid-template-columns: 118px minmax(0, 1fr); align-items: start; gap: 10px; }
.optrow[hidden] { display: none; }
.pl { font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 5px 12px; font: 500 13.5px/1.3 inherit; font-family: inherit; cursor: pointer; }
.chips button:hover { border-color: var(--teal); }
.chips button[aria-checked="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.chips button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.chips button .mth { font-family: 'IBM Plex Mono', monospace; font-size: 12px; opacity: .8; margin-left: 4px; }
.pnote { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.pnote b { color: var(--ink); }
.src { font-size: 13px; }
.src li { margin: 4px 0; }
.params { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 4px; }
.params th, .params td { text-align: left; vertical-align: top; padding: 6px 6px; border-top: 1px solid var(--line); }
.params th { font-weight: 600; white-space: nowrap; }
.params td.tab { color: var(--muted); white-space: nowrap; }
@media (max-width: 820px) {
  .optrow { grid-template-columns: 1fr; gap: 4px; }
  .pl { padding-top: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .chips button { flex: none; }
}

.side-credit { margin: 0; padding: 12px 16px 0; font-size: 12.5px; line-height: 1.5; color: var(--muted, #5A6478); border-top: 1px solid var(--line); }
.side-credit + .side-note { border-top: 0; padding-top: 6px; }
.side-credit a, .credit a { color: #0B7A75; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.credit { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
