      :root {
        --sans:
          system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          sans-serif;
        --mono:
          ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
        --bg: #1b1d21;
        --panel: #24272c;
        --line: #33373e;
        --ink: #eae8e3;
        --mute: #8b919b;
        --edge: #2fb673;
        --corner: #f0a02c;
        --acc: var(--edge);
        /* Cube face colors — user-configurable on the Settings page (persisted to
           IndexedDB, applied here as CSS vars so every drawn sticker recolors live).
           These literals are the built-in defaults / Reset target. */
        --face-U: #ffffff;
        --face-D: #faee0f;
        --face-F: #07de07;
        --face-B: #025aa8;
        --face-R: #ed1111;
        --face-L: #ff6600;
      }
      * {
        box-sizing: border-box;
      }
      body {
        margin: 0;
        background: var(--bg);
        color: var(--ink);
        font-family: var(--sans);
        font-size: 16px;
        line-height: 1.55;
        padding: 0;
      }
      .wrap {
        width: 100%;
        max-width: 700px;
      }

      /* ===== app shell: left sidebar + content ===== */
      .app {
        display: flex;
        align-items: flex-start;
        width: 100%;
      }
      .sidenav {
        flex: 0 0 200px;
        width: 200px;
        box-sizing: border-box;
        align-self: stretch;
        min-height: 100vh;
        position: sticky;
        top: 0;
        padding: 18px 12px;
        border-right: 1px solid var(--line);
      }
      .navbrand {
        font-weight: 800;
        font-size: 15px;
        letter-spacing: -0.01em;
        margin: 0 6px 16px;
      }
      .navgroup {
        margin-bottom: 14px;
      }
      .navgroup-label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--mute);
        font-weight: 700;
        margin: 0 6px 6px;
      }
      .navitem {
        display: block;
        width: 100%;
        text-align: left;
        border: 1px solid transparent;
        border-radius: 7px;
        padding: 8px 10px;
        margin: 2px 0;
        color: var(--mute);
        font-weight: 600;
      }
      .navitem:hover {
        background: var(--panel);
        border-color: transparent;
        color: var(--ink);
      }
      .navitem.on {
        background: var(--panel);
        color: var(--acc);
      }
      .appmain {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        justify-content: center;
        padding: 24px 18px 64px;
      }
      .navtoggle {
        display: none;
      }
      .navbackdrop {
        display: none;
      }
      @media (max-width: 760px) {
        .sidenav {
          position: fixed;
          top: 0;
          left: 0;
          bottom: 0;
          z-index: 60;
          width: 240px;
          flex-basis: 240px;
          min-height: 0;
          background: var(--bg);
          padding-top: 58px; /* clear the fixed hamburger toggle */
          transform: translateX(-100%);
          transition: transform 0.2s ease;
        }
        .sidenav.open {
          transform: translateX(0);
        }
        .navtoggle {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          position: fixed;
          top: 10px;
          left: 10px;
          z-index: 70;
          width: 40px;
          height: 40px;
          padding: 0;
          border-radius: 8px;
          background: var(--panel);
          border: 1px solid var(--line);
          font-size: 18px;
        }
        .navbackdrop.on {
          display: block;
          position: fixed;
          inset: 0;
          z-index: 55;
          background: rgba(10, 11, 13, 0.5);
        }
        .appmain {
          padding-top: 60px;
        }
      }
      h1 {
        font-size: 19px;
        font-weight: 800;
        letter-spacing: -0.01em;
        margin: 0 0 2px;
      }
      .sub {
        color: var(--mute);
        font-size: 14px;
        margin: 0 0 6px;
      }
      .key {
        color: var(--mute);
        font-size: 12.5px;
        margin: 0 0 20px;
      }
      .key b {
        color: #a6adb8;
        font-family: var(--mono);
        font-weight: 600;
      }
      .row {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
        margin-bottom: 14px;
      }
      button {
        font: inherit;
        color: inherit;
        background: none;
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 7px 13px;
        cursor: pointer;
        transition:
          border-color 0.12s,
          background 0.12s,
          color 0.12s;
      }
      button:hover {
        border-color: var(--mute);
      }
      button:focus-visible,
      input:focus-visible {
        outline: 2px solid var(--acc);
        outline-offset: 2px;
      }
      .seg button.on {
        background: var(--acc);
        border-color: var(--acc);
        color: #16181b;
        font-weight: 600;
      }
      button.on {
        border-color: var(--acc);
        color: var(--acc);
      }
      input[type="search"] {
        font: inherit;
        font-family: var(--mono);
        background: var(--panel);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 8px 12px;
        width: 170px;
      }
      .gsel {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        font-size: 13px;
        color: var(--mute);
      }
      .gsel select {
        font: inherit;
        font-size: 13px;
        background: var(--panel);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 7px 9px;
        cursor: pointer;
      }
      .count {
        font-family: var(--mono);
        color: var(--mute);
        font-size: 13px;
      }
      h2 {
        font-size: 14px;
        font-weight: 600;
        margin: 28px 0 8px;
        color: var(--acc);
        font-family: var(--mono);
        letter-spacing: 0.04em;
      }
      h2 span {
        color: var(--mute);
        font-family: var(--sans);
        font-weight: 400;
        letter-spacing: 0;
        margin-left: 8px;
        font-size: 13px;
      }
      #sheet h2.grp {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: baseline;
      }
      #sheet h2.grp .caret {
        color: var(--acc);
        margin: 0 6px 0 0;
        font-size: 12px;
        transition: transform 0.15s;
        transform: none;
      }
      #sheet h2.grp.collapsed .caret {
        transform: rotate(-90deg);
      }
      table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
      }
      td {
        border-bottom: 1px solid var(--line);
        padding: 9px 8px 9px 0;
        vertical-align: top;
      }
      tr.pa td {
        border-bottom: 1px dashed rgba(139, 145, 155, 0.22);
      }
      td.k {
        font-family: var(--mono);
        font-weight: 600;
        width: 44px;
        color: var(--acc);
        padding-top: 10px;
      }
      .algline {
        display: flex;
        align-items: flex-start;
        gap: 8px;
      }
      .a {
        font-family: var(--mono);
        word-spacing: 0.15em;
        font-size: 14.5px;
        flex: 1;
        min-width: 0;
      }
      .sc,
      .c {
        font-family: var(--mono);
        font-size: 12.5px;
        color: var(--mute);
        margin-top: 4px;
        word-spacing: 0.12em;
      }
      .mn {
        font-size: 13px;
        color: var(--ink);
        margin-top: 4px;
      }
      .mn b {
        font-family: var(--sans);
        font-weight: 600;
        color: #a6adb8;
        font-size: 12px;
        margin-right: 6px;
        letter-spacing: 0.02em;
      }
      .kb {
        font-family: var(--sans);
        font-size: 10.5px;
        color: var(--corner);
        border: 1px solid rgba(240, 160, 44, 0.5);
        border-radius: 20px;
        padding: 1px 7px;
        flex: none;
        margin-top: 2px;
      }
      .sc b,
      .c b {
        font-family: var(--sans);
        font-weight: 600;
        color: #a6adb8;
        font-size: 12px;
        letter-spacing: 0.02em;
        margin-right: 5px;
      }
      td.n {
        color: var(--mute);
        width: 26px;
        text-align: right;
        font-family: var(--mono);
        font-size: 12px;
        padding-top: 10px;
      }
      .cp {
        border: none;
        padding: 2px 5px;
        border-radius: 5px;
        color: var(--mute);
        line-height: 0;
        flex: none;
        margin-top: 1px;
      }
      .cp:hover {
        color: var(--ink);
        background: #2e3238;
      }
      .cp svg {
        width: 15px;
        height: 15px;
        display: block;
      }
      .cp.ok {
        color: var(--acc);
      }
      .cp.on,
      .cp.on:hover {
        color: var(--corner);
      }
      .empty {
        color: var(--mute);
        font-size: 14px;
        padding: 20px 0;
      }
      @media (max-width: 440px) {
        .a {
          font-size: 13.5px;
        }
        .sc,
        .c {
          font-size: 12px;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        * {
          transition: none !important;
        }
      }
      .ov {
        position: fixed;
        inset: 0;
        background: rgba(10, 11, 13, 0.82);
        display: none;
        align-items: center;
        justify-content: center;
        padding: 18px;
        z-index: 50;
      }
      .ov.on {
        display: flex;
      }
      .modal {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 16px;
        padding: 20px;
        width: 100%;
        max-width: 420px;
        max-height: 94vh;
        overflow: auto;
      }

      /* Memory-test side panels: docked right, non-blocking (no backdrop) so the
         Solve / Alg-sheet stay visible and usable while a drill runs. */
      .sidepanel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 400px;
        max-width: 100vw;
        box-sizing: border-box;
        z-index: 50;
        background: var(--panel);
        border-left: 1px solid var(--line);
        box-shadow: -10px 0 28px rgba(0, 0, 0, 0.38);
        padding: 20px 20px 28px;
        overflow: auto;
        transform: translateX(100%);
        transition: transform 0.22s ease;
      }
      .sidepanel.on {
        transform: translateX(0);
      }
      .sidepanel .modal {
        background: none;
        border: 0;
        border-radius: 0;
        padding: 0;
        max-width: none;
        max-height: none;
        overflow: visible;
        width: 100%;
      }
      /* content shift is instant (no layout-property animation); the panel's
         own transform handles the visible motion */
      body.sidepanel-open .appmain {
        padding-right: 416px;
      }
      @media (max-width: 760px) {
        .sidepanel {
          width: 100vw;
          border-left: 0;
          box-shadow: none;
        }
        body.sidepanel-open .appmain {
          padding-right: 18px;
        }
      }
      .mhead {
        display: flex;
        align-items: baseline;
        gap: 10px;
        margin-bottom: 2px;
      }
      .mhead .kk {
        font-family: var(--mono);
        font-weight: 800;
        font-size: 26px;
        color: var(--acc);
      }
      .mhead .grp {
        color: var(--mute);
        font-size: 13px;
      }
      .legend {
        margin: 10px 0 14px;
        font-size: 12.5px;
      }
      .lg {
        display: grid;
        grid-template-columns: 88px auto 1fr;
        gap: 4px 10px;
        align-items: baseline;
        padding: 2px 0;
      }
      .lg > span {
        color: var(--mute);
      }
      .lg > b {
        color: var(--ink);
        font-family: var(--mono);
        font-weight: 600;
        font-size: 13.5px;
        white-space: nowrap;
      }
      .lg > i {
        color: var(--mute);
        font-style: normal;
        font-family: var(--mono);
        font-size: 12px;
      }
      .lgsep {
        height: 1px;
        background: var(--line);
        margin: 9px 0;
      }
      .lgnote {
        color: var(--mute);
        font-size: 11.5px;
        margin-top: 7px;
      }
      #stage {
        width: 100%;
        display: flex;
        justify-content: center;
      }
      #stage canvas {
        touch-action: none;
        cursor: grab;
      }
      #stage canvas:active {
        cursor: grabbing;
      }
      .mmoves {
        font-family: var(--mono);
        font-size: 14px;
        margin: 12px 0 4px;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
      }
      .mv {
        padding: 2px 6px;
        border-radius: 5px;
        color: var(--mute);
      }
      .mv.cur {
        background: var(--acc);
        color: #16181b;
        font-weight: 600;
      }
      .ctrls {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 14px;
      }
      .ib {
        width: 38px;
        height: 38px;
        padding: 0;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: var(--mute);
        flex: none;
      }
      .ib:hover {
        color: var(--ink);
        border-color: var(--mute);
      }
      .ib svg {
        width: 17px;
        height: 17px;
        display: block;
      }
      .ib.main {
        background: var(--acc);
        border-color: var(--acc);
        color: #16181b;
        width: 44px;
        height: 44px;
      }
      .ib.main svg {
        width: 19px;
        height: 19px;
      }
      .ib.main:hover {
        color: #16181b;
        filter: brightness(1.08);
      }
      .ib[disabled] {
        opacity: 0.35;
        cursor: default;
      }
      .ib[disabled]:hover {
        color: var(--mute);
        border-color: var(--line);
      }
      .hide {
        display: none !important;
      }
      .ptabs {
        display: flex;
        gap: 2px;
        border-bottom: 1px solid var(--line);
        margin: 0 0 18px;
      }
      .ptabs button {
        border: none;
        border-bottom: 2px solid transparent;
        border-radius: 0;
        padding: 9px 15px;
        color: var(--mute);
      }
      .ptabs button.on {
        color: var(--ink);
        border-bottom-color: var(--acc);
        font-weight: 600;
      }
      #mapBox {
        margin-top: 6px;
      }

      .mrow2 {
        display: grid;
        grid-template-columns: 64px 92px 1fr;
        align-items: center;
        gap: 16px;
        padding: 8px 4px;
        border-bottom: 1px solid var(--line);
      }
      .mrow2.mhd {
        color: var(--mute);
        font-size: 11.5px;
        border-bottom: 1px solid var(--line);
        text-transform: none;
      }
      .mrow2 .ml {
        font-family: var(--mono);
        font-weight: 700;
        font-size: 16px;
        color: var(--acc);
      }
      .mchips {
        display: flex;
        gap: 3px;
      }
      .mpiece {
        display: flex;
        align-items: center;
      }
      .pc {
        border: 1px solid rgba(0, 0, 0, 0.4);
        display: block;
      }

      .main2 {
        background: var(--acc);
        border-color: var(--acc);
        color: #16181b;
        font-weight: 600;
      }
      .main2:hover {
        filter: brightness(1.08);
        border-color: var(--acc);
      }
      .c25 {
        display: block;
      }
      .c25 polygon {
        stroke-linejoin: round;
      }
      .mnm {
        font-family: var(--mono);
        font-size: 13px;
        color: var(--mute);
      }
      @media (max-width: 440px) {
        .mrow2 {
          grid-template-columns: 52px 84px 1fr;
          gap: 12px;
        }
      }
      #net,
      .ci-net {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        grid-template-rows: repeat(9, 1fr);
        gap: 2px;
        margin: 6px 0 12px;
      }
      .st {
        aspect-ratio: 1;
        background: #2b2f35;
        border-radius: 3px;
        cursor: pointer;
      }
      .st:hover {
        outline: 1.5px solid var(--mute);
      }
      .st.cen {
        cursor: default;
      }
      .st.cen:hover {
        outline: none;
      }
      .st.cur {
        outline: 2.5px solid var(--acc);
        outline-offset: 1px;
        z-index: 2;
      }
      .keys {
        color: var(--mute);
        font-size: 12px;
        margin: 2px 0 10px;
        line-height: 1.7;
      }
      .keys kbd {
        font-family: var(--mono);
        background: #2b2f35;
        border: 1px solid var(--line);
        border-radius: 4px;
        padding: 1px 5px;
        color: var(--ink);
        font-size: 11.5px;
      }
      #pick {
        position: absolute;
        display: none;
        gap: 5px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 9px;
        padding: 7px;
        z-index: 40;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
      }
      #pick.on {
        display: flex;
      }
      .sw {
        width: 28px;
        height: 28px;
        padding: 0;
        border-radius: 6px;
        border: 1px solid rgba(0, 0, 0, 0.35);
      }
      .sw.off {
        opacity: 0.25;
        cursor: default;
      }
      .sw.clr {
        background: none;
        border: 1px solid var(--line);
        color: var(--mute);
        font-size: 15px;
      }
      #wrap {
        position: relative;
      }
      .err {
        display: none;
        color: #e8837c;
        font-size: 13px;
        background: rgba(212, 72, 63, 0.09);
        border: 1px solid rgba(212, 72, 63, 0.3);
        border-radius: 8px;
        padding: 10px 12px;
        margin: 10px 0;
      }
      .err.on {
        display: block;
      }
      .fl {
        display: block;
        font-size: 13px;
        color: var(--mute);
        margin: 6px 0 6px;
      }
      .scrbar {
        display: flex;
        gap: 8px;
        align-items: flex-start;
        margin-bottom: 4px;
      }
      .scrwrap {
        flex: 1;
        position: relative;
        display: flex;
        min-width: 0;
      }
      .scrwrap textarea {
        width: 100%;
        box-sizing: border-box;
        font-family: var(--mono);
        font-size: 14px;
        line-height: 1.6;
        background: var(--panel);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 9px 40px 9px 12px;
        resize: none;
        overflow: hidden;
        white-space: pre-wrap;
        word-break: break-word;
        display: block;
        field-sizing: content;
        min-height: 38px;
      }
      .scrwrap textarea.bad {
        border-color: rgba(212, 72, 63, 0.6);
      }
      .incopy {
        position: absolute;
        right: 6px;
        top: 7px;
        border: none;
        background: none;
        color: var(--mute);
        padding: 4px;
        border-radius: 6px;
        cursor: pointer;
        line-height: 0;
      }
      .incopy:hover {
        color: var(--ink);
        background: #2e3238;
      }
      .incopy svg {
        width: 15px;
        height: 15px;
        display: block;
      }
      .incopy.ok {
        color: var(--acc);
      }
      .scrbar button {
        flex: none;
      }
      .orsep {
        color: var(--mute);
        font-size: 13px;
        margin: 16px 0 8px;
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .orsep::before,
      .orsep::after {
        content: "";
        height: 1px;
        background: var(--line);
        flex: 1;
      }
      .memo {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 12px 14px;
        margin: 14px 0;
      }
      #svOut .ce,
      .ce {
        color: var(--edge);
      }
      #svOut .cc,
      .cc {
        color: var(--corner);
      }
      #svOut h3.ce {
        color: var(--edge);
      }
      #svOut h3.cc {
        color: var(--corner);
      }
      #svOut .sh b.ce {
        color: var(--edge);
      }
      #svOut .sh b.cc {
        color: var(--corner);
      }
      #svOut .mrow b.ce {
        color: var(--edge);
      }
      #svOut .mrow b.cc {
        color: var(--corner);
      }
      .mrow {
        display: flex;
        gap: 12px;
        align-items: baseline;
        padding: 3px 0;
      }
      .mrow span {
        color: var(--mute);
        font-size: 12.5px;
        width: 78px;
        flex: none;
      }
      .mrow b {
        font-family: var(--mono);
        font-size: 16px;
        letter-spacing: 0.12em;
      }
      #svOut h3 {
        font-size: 13px;
        font-weight: 600;
        margin: 22px 0 8px;
        color: var(--acc);
        font-family: var(--mono);
        letter-spacing: 0.04em;
      }
      #svOut h3 span {
        color: var(--mute);
        font-family: var(--sans);
        font-weight: 400;
        font-size: 12.5px;
        margin-left: 7px;
      }
      .step {
        border-bottom: 1px solid var(--line);
        padding: 9px 0;
      }
      .sh {
        display: flex;
        align-items: center;
        gap: 9px;
      }
      .sh b {
        font-family: var(--mono);
        font-size: 14.5px;
        color: var(--ink);
      }
      .tag {
        font-size: 11px;
        color: var(--mute);
        border: 1px solid var(--line);
        border-radius: 20px;
        padding: 1px 8px;
      }
      .tag.warn {
        color: var(--corner);
        border-color: rgba(240, 160, 44, 0.4);
      }
      .sm {
        color: var(--mute);
        font-size: 12px;
        font-family: var(--mono);
      }
      .sa {
        font-family: var(--mono);
        font-size: 14px;
        word-spacing: 0.15em;
        margin-top: 5px;
      }
      .pnote {
        color: var(--mute);
        font-size: 12.5px;
        margin: 9px 0 0;
        line-height: 1.6;
      }
      .phead {
        display: flex;
        align-items: baseline;
        gap: 9px;
        flex-wrap: wrap;
      }
      .psub {
        margin: 9px 0 0;
        padding-left: 10px;
        border-left: 2px solid var(--line);
      }
      .psub .pll {
        font-family: var(--mono);
        font-weight: 600;
        font-size: 13px;
        color: var(--acc);
      }
      .psub .pnn {
        color: var(--mute);
        font-size: 11.5px;
      }
      .psub .sa {
        margin-top: 3px;
      }

      .none {
        color: var(--mute);
        font-size: 13px;
        margin: 8px 0;
      }
      @media (max-width: 440px) {
        .st {
          border-radius: 2px;
        }
        #net,
        .ci-net {
          gap: 1.5px;
        }
      }

      #scrOut {
        margin: 2px 0 10px;
      }
      #scrOut .sa {
        color: var(--acc);
      }

      @media (max-width: 520px) {
      }
      .spd {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: 12px;
      }
      .spd label {
        font-size: 12.5px;
        color: var(--mute);
        flex: none;
      }
      .spd output {
        font-family: var(--mono);
        font-size: 12.5px;
        color: var(--acc);
        width: 34px;
        text-align: right;
        flex: none;
      }
      input[type="range"] {
        -webkit-appearance: none;
        appearance: none;
        flex: 1;
        height: 22px;
        background: none;
        cursor: pointer;
      }
      input[type="range"]::-webkit-slider-runnable-track {
        height: 3px;
        background: var(--line);
        border-radius: 2px;
      }
      input[type="range"]::-moz-range-track {
        height: 3px;
        background: var(--line);
        border-radius: 2px;
      }
      input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: var(--acc);
        margin-top: -5.5px;
      }
      input[type="range"]::-moz-range-thumb {
        width: 14px;
        height: 14px;
        border: none;
        border-radius: 50%;
        background: var(--acc);
      }
      .close {
        position: absolute;
        top: 16px;
        right: 16px;
      }

      /* ===== reusable cube input (createCubeInput) + CFOP page ===== */
      .ci-scrrow {
        display: flex;
        gap: 8px;
        align-items: flex-end;
        flex-wrap: wrap;
        margin-bottom: 8px;
      }
      .ci-field { flex: 1 1 260px; min-width: 220px; }
      .ci-field label {
        display: block;
        color: var(--mute);
        font-size: 13px;
        margin-bottom: 4px;
      }
      .ci-scrwrap { position: relative; }
      .ci-scr {
        width: 100%;
        box-sizing: border-box;
        font-family: var(--mono);
        font-size: 14px;
        line-height: 1.6;
        background: var(--panel);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 9px 34px 9px 11px;
        resize: none;
        overflow: hidden;
        white-space: pre-wrap;
        word-break: break-word;
        display: block;
        field-sizing: content;
        min-height: 38px;
      }
      .ci-scr.bad { border-color: var(--r, #d4483f); }
      .ci-copy {
        position: absolute;
        top: 6px;
        right: 6px;
        border: none;
        padding: 4px;
        color: var(--mute);
        background: none;
        cursor: pointer;
      }
      .ci-copy:hover { color: var(--ink); }
      .ci-or { text-align: center; margin: 10px 0 6px; }
      .ci-pick {
        position: absolute;
        display: none;
        gap: 4px;
        padding: 6px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        z-index: 40;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      }
      .ci-pick.on { display: flex; }
      .ci-pick .sw {
        width: 26px;
        height: 26px;
        border-radius: 5px;
        border: 1px solid var(--line);
        cursor: pointer;
      }
      .ci-pick .sw.off { opacity: 0.3; cursor: not-allowed; }
      .ci-pick .sw.clr { background: transparent; color: var(--mute); font-size: 16px; }
      .cfop-out { margin-top: 14px; }
      .cfop-out .step { margin-bottom: 10px; }
      .cfop-c { color: var(--acc); }
      .cfop-f { color: #6ea8ff; }
      .cfop-o { color: #f3cf3a; }
      .cfop-p { color: #e08a2b; }

      /* ===== CFOP cross-color (D layer) picker ===== */
      .cfop-dpick {
        position: relative;
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 2px 0 12px;
      }
      .cfop-dlabel { color: var(--mute); font-size: 13px; }
      .cfop-dsw {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        border: 1px solid var(--line);
        padding: 0;
        cursor: pointer;
      }
      .cfop-dsw:hover { border-color: var(--mute); }
      .cfop-dpop[hidden] { display: none; }
      .cfop-dpop {
        position: absolute;
        top: 32px;
        left: 0;
        z-index: 45;
        display: flex;
        gap: 5px;
        padding: 7px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 9px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      }
      .cfop-dopt {
        width: 26px;
        height: 26px;
        border-radius: 5px;
        border: 1px solid var(--line);
        padding: 0;
        cursor: pointer;
      }
      .cfop-dopt:hover { transform: scale(1.08); }

      .cfop-hold {
        color: var(--mute);
        font-size: 13px;
        margin: 4px 0 14px;
      }
      .cfop-hold b { color: var(--ink); font-weight: 600; }

      /* ---- Speffz memory test ---- */
      .mtfield {
        display: block;
        margin: 10px 0;
      }
      .mtfield > span {
        display: block;
        font-size: 12px;
        color: var(--mute);
        margin-bottom: 4px;
      }
      .mtfield input {
        font: inherit;
        font-family: var(--mono);
        background: var(--bg);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 8px 12px;
        width: 100%;
      }
      .mtbar {
        height: 5px;
        border-radius: 3px;
        background: var(--line);
        overflow: hidden;
      }
      .mtbar-fill {
        height: 100%;
        width: 100%;
        background: var(--acc);
        transform-origin: left;
        /* scaleX is driven inline each frame (compositor-only, no layout);
           linear so the bar reads as elapsed time */
        transition: transform 0.1s linear;
      }
      .mtstage {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 180px;
        margin: 18px 0 6px;
      }
      /* the piece icon is a 40x40 svg (.c25) — scale it up big for the test */
      #mtPiece .c25 {
        width: 128px;
        height: 128px;
      }
      .mtstage.flash-ok { animation: mtOk 0.25s ease; }
      .mtstage.flash-bad { animation: mtBad 0.6s ease; }
      @keyframes mtOk {
        0% { background: rgba(47, 182, 115, 0.35); }
        100% { background: transparent; }
      }
      @keyframes mtBad {
        0% { background: rgba(212, 72, 63, 0.35); }
        100% { background: transparent; }
      }
      .mtverdict {
        position: absolute;
        bottom: 6px;
        left: 0;
        right: 0;
        text-align: center;
        font-family: var(--mono);
        font-size: 15px;
        min-height: 20px;
      }
      .mtverdict.ok { color: var(--edge); }
      .mtverdict.bad { color: #d4483f; }
      .mtmeta {
        display: flex;
        justify-content: space-between;
        font-family: var(--mono);
        font-size: 13px;
        color: var(--mute);
      }
      .mtscore {
        font-size: 15px;
        line-height: 1.7;
        margin: 8px 0 14px;
      }
      .mtscore b {
        font-family: var(--mono);
        color: var(--ink);
      }
      .mtmisses {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
      }
      .mtmiss {
        display: flex;
        align-items: center;
        gap: 6px;
        border: 1px solid var(--line);
        border-radius: 7px;
        padding: 4px 8px;
        font-family: var(--mono);
        font-size: 13px;
      }
      .mtmiss .c25 { width: 28px; height: 28px; }
      .mtmiss .n { color: #d4483f; }

      /* ---- Alg-sheet memory test ---- */
      .atpickhead {
        display: flex;
        align-items: center;
        gap: 8px;
        font-family: var(--mono);
        font-size: 12px;
        color: var(--mute);
        margin-bottom: 8px;
      }
      .atquick {
        font-size: 12px;
        padding: 3px 9px;
      }
      .atpick {
        max-height: 260px;
        overflow-y: auto;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 10px 12px;
      }
      .atgrp {
        margin-bottom: 12px;
      }
      .atgrp:last-child {
        margin-bottom: 0;
      }
      .atgrph {
        display: flex;
        align-items: center;
        gap: 7px;
        cursor: pointer;
        user-select: none;
        font-family: var(--mono);
        font-size: 12px;
        color: var(--acc);
        margin-bottom: 6px;
      }
      .atgrph .cb {
        font-size: 14px;
      }
      .atgrph .gn {
        color: var(--mute);
        margin-left: 2px;
      }
      .atchips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }
      .atchip {
        font-family: var(--mono);
        font-size: 13px;
        padding: 4px 9px;
        border: 1px solid var(--line);
        border-radius: 7px;
        cursor: pointer;
        user-select: none;
        color: var(--mute);
        white-space: nowrap;
      }
      .atchip.on {
        background: var(--acc);
        color: #06110b;
        border-color: var(--acc);
        font-weight: 600;
      }
      .atstack {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
        width: 100%;
      }
      #atPair {
        font-family: var(--mono);
        font-weight: 700;
        font-size: 52px;
        letter-spacing: 0.06em;
        color: var(--ink);
        text-align: center;
        line-height: 1.05;
      }
      .atreveal {
        min-height: 46px;
        text-align: center;
        font-family: var(--mono);
      }
      .atreveal .a {
        font-size: 20px;
        color: var(--acc);
        word-break: break-word;
      }
      .atreveal .sc {
        display: block;
        margin-top: 8px;
        font-size: 12px;
        color: var(--mute);
      }
      .mtstage.flash {
        animation: mtOk 0.4s ease;
      }
      .mtstage.apaused {
        opacity: 0.45;
      }
      .extext {
        width: 100%;
        box-sizing: border-box;
        min-height: 240px;
        max-height: 50vh;
        font-family: var(--mono);
        font-size: 12px;
        line-height: 1.5;
        background: var(--bg);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 10px 12px;
        resize: vertical;
      }

      /* ---- Settings page ---- */
      .set-section h2 {
        font-size: 16px;
        margin: 4px 0 4px;
      }
      .set-colors {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
        margin: 14px 0 18px;
      }
      .set-color {
        display: flex;
        align-items: center;
        gap: 10px;
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
      }
      .set-color input[type="color"] {
        width: 34px;
        height: 34px;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: none;
        cursor: pointer;
        flex: 0 0 auto;
      }
      .set-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
      .set-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
      .set-color-name {
        font-weight: 600;
        font-size: 14px;
      }
      .set-color-pos {
        font-family: var(--mono);
        font-size: 12px;
        color: var(--mute);
        margin-left: auto;
      }
      .set-reset {
        font-size: 13px;
      }

      /* print-only container holding both Edges + Corners (filled on print) */
      #printArea {
        display: none;
      }

      /* ===== Print: the Alg sheet as a clean "letter pair | alg" table ===== */
      @media print {
        @page {
          margin: 12mm;
        }
        html,
        body {
          background: #fff !important;
        }

        /* hide the app chrome and everything that isn't the alg table */
        .sidenav,
        .navtoggle,
        .navbackdrop,
        .ov,
        .sidepanel,
        #view-cfop,
        #view-settings,
        #wrap > h1,
        #wrap > .sub,
        #wrap > .key,
        #wrap > .ptabs,
        #pageSolve,
        #pageMap,
        #pageAlg > .row,
        #sheet {
          display: none !important;
        }

        .app {
          display: block !important;
        }
        .appmain {
          display: block !important;
          padding: 0 !important;
        }
        #wrap {
          max-width: none !important;
          width: 100% !important;
        }
        /* print the alg sheet even if another inner tab is currently active */
        #pageAlg {
          display: block !important;
        }
        /* both Edges + Corners are rendered here just before printing */
        #printArea {
          display: block !important;
        }

        /* inside each row keep only the letter pair + the alg */
        #printArea .cp,
        #printArea .kb,
        #printArea .mn,
        #printArea .sc,
        #printArea .c,
        #printArea td.n,
        #printArea h2 span {
          display: none !important;
        }

        #printArea {
          color: #000 !important;
        }
        #printArea .printmode {
          color: #000 !important;
          font-size: 15px;
          font-weight: 800;
          margin: 4px 0 8px;
          padding-bottom: 3px;
          border-bottom: 2px solid #000;
        }
        #printArea .printmode-c {
          break-before: page;
          page-break-before: always;
        }
        #printArea h2 {
          color: #000 !important;
          font-size: 12px;
          margin: 12px 0 5px;
          page-break-after: avoid;
          break-after: avoid;
        }

        /* Two columns via inline-block rows in NORMAL flow, so the content
           paginates across pages. (CSS `column-count` collapses to a single
           page in Chrome's print preview — that was the 1-page bug.)
           display:block on the table also force-expands collapsed groups. */
        #printArea table {
          display: block !important;
          border: 0 !important;
          font-size: 0; /* collapse the whitespace between inline-block rows */
        }
        #printArea tbody {
          display: block;
        }
        #printArea tr {
          display: inline-block !important;
          width: 48.7%;
          box-sizing: border-box;
          vertical-align: top;
          break-inside: avoid;
          page-break-inside: avoid;
          border: 1px solid #ccc !important;
          border-radius: 4px;
          padding: 2px 7px !important;
          margin: 0 2.4% 4px 0 !important;
          font-size: 11px;
          line-height: 1.35;
          background: #fff !important;
        }
        #printArea tr:nth-of-type(2n) {
          margin-right: 0 !important;
        }
        #printArea tr.pa {
          background: #fff !important;
        }
        /* pair | alg as two fixed side-by-side columns inside each row, so a
           long aka label (e.g. "AE / ER / RA") can't overlap the alg — it wraps
           within its own 30% column instead. */
        #printArea td {
          display: inline-block !important;
          vertical-align: top;
          box-sizing: border-box;
          border: 0 !important;
          padding: 0 !important;
          color: #000 !important;
          background: transparent !important;
        }
        #printArea td.k {
          width: 30%;
          padding-right: 5px !important;
          font-weight: 700;
        }
        #printArea td:not(.k) {
          width: 70%;
        }
        #printArea .algline {
          display: inline !important;
        }
        #printArea .a {
          color: #000 !important;
        }
      }
