.linked-list-lab {
  --ll-blue: #087cad;
  --ll-blue-soft: #e7f6fc;
  --ll-navy: #08233a;
  --ll-green: #25834a;
  --ll-amber: #d99000;
  background: linear-gradient(145deg, #f9fdff 0%, #eef8fc 100%);
  border: 1px solid #bcddea;
  border-radius: 1.15rem;
  box-shadow: 0 15px 38px rgba(10, 73, 105, .1);
  margin: 2rem 0;
  overflow: hidden;
}
.ll-header { align-items: flex-start; background: linear-gradient(130deg, var(--ll-navy), #075b82); color: #fff; display: flex; gap: 1.25rem; justify-content: space-between; padding: 1.35rem 1.5rem; }
.ll-header h3 { color: #fff; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.035em; margin: .15rem 0 .25rem; }
.ll-header p { color: #d2e9f4; margin: 0; }
.ll-kicker { color: #74d6ff !important; font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.ll-type-badges { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: .45rem; }
.ll-type-badges span { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; color: #fff; font-size: .75rem; font-weight: 700; padding: .35rem .6rem; }

.ll-stage-panel { background: #fff; border-bottom: 1px solid #d8e6ed; padding: 1rem 1.25rem .85rem; }
.ll-stage-toolbar { align-items: center; display: flex; justify-content: space-between; margin-bottom: .85rem; }
.ll-stage-toolbar > span { background: var(--ll-blue-soft); border-radius: 999px; color: #076d98; font-family: Consolas, monospace; font-size: .78rem; font-weight: 700; padding: .3rem .58rem; }
.ll-stage-scroll { overflow-x: auto; padding: 1.4rem .15rem .8rem; scrollbar-width: thin; }
.ll-stage { align-items: center; display: flex; justify-content: center; min-height: 126px; min-width: max-content; padding: 0 .5rem; }
.ll-node-wrap { align-items: center; display: flex; position: relative; }
.ll-node-labels { display: flex; gap: .25rem; left: 50%; position: absolute; top: -1.55rem; transform: translateX(-50%); }
.ll-pointer-label { border-radius: .35rem; color: #fff; font-size: .64rem; font-weight: 800; letter-spacing: .05em; padding: .16rem .35rem; }
.ll-head-label { background: var(--ll-blue); }
.ll-tail-label { background: #7b4bb7; }
.ll-node { border: 2px solid #80bdd6; border-radius: .75rem; box-shadow: 0 7px 15px rgba(21, 78, 108, .09); display: grid; grid-template-columns: 44px minmax(62px, auto) 44px; overflow: hidden; transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease; }
.ll-node > span { align-items: center; display: flex; justify-content: center; min-height: 64px; padding: .45rem; }
.ll-node-prev, .ll-node-next { background: #e8f4f9; color: #4a7285; font-family: Consolas, monospace; font-size: .72rem; }
.ll-node-data { background: #fff; color: var(--ll-navy); font-family: Consolas, monospace; font-size: 1rem; font-weight: 800; }
.ll-node.is-active { border-color: #e09a0e; box-shadow: 0 0 0 4px rgba(224,154,14,.15), 0 9px 20px rgba(21,78,108,.12); transform: translateY(-4px); }
.ll-node.is-visited .ll-node-data { background: #fff2ce; }
.ll-link { color: #4d8299; font-size: 1.35rem; font-weight: 800; padding: 0 .35rem; }
.ll-null { color: #75899a; font-family: Consolas, monospace; font-size: .82rem; padding: 0 .45rem; }
.ll-empty { align-items: center; background: #f5f8fa; border: 2px dashed #bdcdd6; border-radius: .85rem; color: #657987; display: flex; gap: .6rem; justify-content: center; min-height: 82px; min-width: 260px; padding: 1rem; }
.ll-legend { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; margin-top: .4rem; }
.ll-legend span { align-items: center; color: #5d7180; display: flex; font-size: .72rem; gap: .3rem; }
.ll-swatch { border-radius: .2rem; display: inline-block; height: .7rem; width: .9rem; }
.ll-swatch-link { background: #dceef5; }
.ll-swatch-data { background: #fff; border: 1px solid #a8c6d3; }
.ll-swatch-active { background: #fff2ce; border: 1px solid #e09a0e; }

.ll-inputs { align-items: end; background: #f6fafc; border-bottom: 1px solid #d8e6ed; display: grid; gap: .8rem; grid-template-columns: minmax(160px, 1fr) minmax(130px, .55fr) auto; padding: 1rem 1.25rem; }
.ll-inputs label { color: #334b5e; font-size: .78rem; font-weight: 800; }
.ll-inputs input { background: #fff; border: 1px solid #aec4d0; border-radius: .55rem; color: var(--lesson-ink); display: block; font: inherit; font-weight: 500; margin-top: .3rem; min-height: 42px; padding: .45rem .65rem; width: 100%; }
.ll-inputs input:focus { border-color: var(--ll-blue); box-shadow: 0 0 0 3px rgba(8,124,173,.14); outline: 0; }
.ll-inputs small { color: #6c7e8c; display: block; font-size: .68rem; font-weight: 500; margin-top: .18rem; }
.ll-reset { align-items: center; background: #fff; border: 1px solid #aec4d0; border-radius: .55rem; color: #294356; display: flex; gap: .4rem; min-height: 42px; padding: .45rem .75rem; }

.ll-method-groups { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 1rem 1.25rem; }
.ll-method-groups details { align-self: start; background: #fff; border: 1px solid #d2e1e8; border-radius: .8rem; overflow: hidden; }
.ll-method-groups summary { align-items: center; cursor: pointer; display: flex; justify-content: space-between; list-style: none; min-height: 52px; padding: .65rem .85rem; }
.ll-method-groups summary::-webkit-details-marker { display: none; }
.ll-method-groups summary::after { color: #618093; content: "+"; font-size: 1.15rem; margin-left: .5rem; }
.ll-method-groups details[open] summary::after { content: "−"; }
.ll-method-groups summary span { color: #19394e; font-weight: 800; }
.ll-method-groups summary small { color: #6b7e8c; font-size: .72rem; margin-left: auto; }
.ll-method-buttons { border-top: 1px solid #e3ebef; display: flex; flex-wrap: wrap; gap: .45rem; padding: .7rem; }
.ll-method-buttons button { background: #f1f8fb; border: 1px solid #bdd8e5; border-radius: .5rem; color: #075f87; min-height: 38px; padding: .38rem .58rem; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.ll-method-buttons button:hover { background: #dff3fb; border-color: var(--ll-blue); transform: translateY(-1px); }
.ll-method-buttons code { color: inherit; font-size: .78rem; }

.ll-explanation { background: var(--ll-navy); color: #eef8fc; margin: 0 1.25rem 1rem; padding: 1rem 1.1rem; border-radius: .85rem; }
.ll-operation-top { align-items: center; display: flex; flex-wrap: wrap; gap: .65rem; justify-content: space-between; }
.ll-operation-top > span { background: #fff1c6; border-radius: 999px; color: #825700; font-size: .72rem; font-weight: 800; padding: .28rem .52rem; }
.ll-operation-top code { color: #90ddff; font-size: .82rem; }
.ll-explanation > p { color: #d6e8f1; margin: .7rem 0; }
.ll-result { align-items: center; border-top: 1px solid rgba(255,255,255,.14); display: flex; gap: .65rem; padding-top: .65rem; }
.ll-result strong { color: #8bdcff; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.ll-result span { color: #fff; }

.ll-tour { align-items: center; background: linear-gradient(120deg, #fff7dd, #fffdf7); border-top: 1px solid #ead79b; display: grid; gap: 1.2rem; grid-template-columns: minmax(0, 1fr) auto; padding: 1.1rem 1.25rem; }
.ll-tour .ll-kicker { color: #9b6700 !important; }
.ll-tour h4 { font-size: 1.15rem; margin: .1rem 0 .2rem; }
.ll-tour p { color: #6d5b30; margin: 0; }
.ll-tour-controls { text-align: right; }
.ll-tour-controls > span { color: #765f24; display: block; font-size: .75rem; font-weight: 800; margin-bottom: .4rem; }
.ll-tour-controls > div { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.ll-tour-controls button { align-items: center; background: #fff; border: 1px solid #d5bb72; border-radius: .5rem; color: #674c08; display: inline-flex; gap: .25rem; min-height: 38px; padding: .38rem .58rem; }
.ll-tour-controls .ll-tour-play { background: #8c6400; border-color: #8c6400; color: #fff; }

@keyframes ll-node-pulse { 0% { transform: translateY(0) scale(.96); opacity: .55; } 100% { transform: translateY(-4px) scale(1); opacity: 1; } }
.linked-list-lab.is-animating .ll-node.is-active { animation: ll-node-pulse .42s ease-out; }

@media (max-width: 760px) {
  .ll-header { flex-direction: column; padding: 1.05rem; }
  .ll-inputs { grid-template-columns: 1fr 1fr; padding: .85rem; }
  .ll-reset { grid-column: 1 / -1; justify-content: center; }
  .ll-method-groups { grid-template-columns: 1fr; padding: .85rem; }
  .ll-explanation { margin: 0 .85rem .85rem; }
  .ll-tour { align-items: stretch; grid-template-columns: 1fr; padding: .95rem; }
  .ll-tour-controls { text-align: left; }
  .ll-tour-controls > div { justify-content: flex-start; }
  .ll-stage-panel { padding-left: .85rem; padding-right: .85rem; }
  .ll-stage { justify-content: flex-start; }
}
@media (max-width: 440px) {
  .ll-inputs { grid-template-columns: 1fr; }
  .ll-reset { grid-column: auto; }
  .ll-method-groups summary small { display: none; }
  .ll-node { grid-template-columns: 34px minmax(50px, auto) 34px; }
  .ll-node > span { min-height: 56px; padding: .3rem; }
  .ll-link { padding: 0 .2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .linked-list-lab *, .linked-list-lab *::before, .linked-list-lab *::after { animation: none !important; transition: none !important; }
}
@media print {
  .ll-inputs, .ll-method-groups, .ll-tour-controls { display: none !important; }
  .linked-list-lab { break-inside: avoid; box-shadow: none; }
  .ll-stage-scroll { overflow: visible; }
}
