:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #f6f3fc;
  background: #101019;
  --bg: #101019;
  --panel: #161621;
  --surface: #1c1b29;
  --line: #302d40;
  --muted: #aba6bc;
  --accent: #c0a6ff;
  --ink-on-accent: #1c1130;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --radius: 16px;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 300px; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .42; }
button[hidden], [hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.shell { max-width: 1408px; width: calc(100% - 112px); margin-inline: auto; }
.topbar { height: 67px; border-bottom: 1px solid #292638; background: #12111b; }
.topbar-inner { height: 100%; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand {
  display: inline-flex; align-items: center; gap: 11px;
  text-decoration: none; font: 800 19px/1 var(--mono); letter-spacing: -.06em;
}
.brand-accent { color: var(--accent); margin-left: .18em; }
.brand-mark { display: block; width: 27px; height: 29px; position: relative; }
.brand-mark i { position: absolute; display: block; background: #d5bcff; inset: 0; }
.brand-mark i:nth-child(1) { clip-path: polygon(50% 1%, 96% 25%, 50% 48%, 4% 25%); }
.brand-mark i:nth-child(2) { background: #a17ef3; clip-path: polygon(4% 30%, 47% 53%, 47% 99%, 4% 75%); }
.brand-mark i:nth-child(3) { background: #754dda; clip-path: polygon(96% 30%, 53% 53%, 53% 99%, 96% 75%); }
.quiet-button {
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  color: #c5bed5; display: inline-flex; align-items: center; justify-content: center;
  gap: .45rem; min-height: 38px; padding: 0 .65rem; white-space: nowrap; font-size: .875rem;
}
.quiet-button:not(:disabled):hover { background: #242036; color: #f3ebff; }
.shortcut-trigger { border-color: #343047; padding-inline: 12px; }
.icon { display: inline-grid; place-items: center; flex: none; width: 1.15em; height: 1.15em; font: 500 1.23rem/1 var(--mono); }
.keyboard-icon {
  width: 16px; height: 11px; font-size: 0; border: 1px solid currentColor;
  border-radius: 2px; position: relative;
}
.keyboard-icon::before { content: "···"; font: 800 14px/7px var(--mono); letter-spacing: -3px; position: absolute; top: -1px; left: 0; }
.keyboard-icon::after { content: ""; width: 6px; height: 1px; background: currentColor; position: absolute; bottom: 2px; left: 4px; }
.corners-icon {
  width: 15px; height: 15px;
  background:
    linear-gradient(currentColor,currentColor) 0 0/5px 1px, linear-gradient(currentColor,currentColor) 0 0/1px 5px,
    linear-gradient(currentColor,currentColor) 100% 0/5px 1px, linear-gradient(currentColor,currentColor) 100% 0/1px 5px,
    linear-gradient(currentColor,currentColor) 0 100%/5px 1px, linear-gradient(currentColor,currentColor) 0 100%/1px 5px,
    linear-gradient(currentColor,currentColor) 100% 100%/5px 1px, linear-gradient(currentColor,currentColor) 100% 100%/1px 5px;
  background-repeat: no-repeat;
}
#lab { scroll-margin-top: 32px; }
.lab-heading { padding: 40px 0 28px; }
.lab-heading h1 { font-size: clamp(2.5rem, 4.2vw, 3.75rem); line-height: 1.15; letter-spacing: -.055em; font-weight: 850; }
.lab-heading h1 span { color: #c5aaff; }
.lab-heading p { margin-top: 13px; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; gap: 18px; }
.studio, .console, .guide-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.studio { overflow: hidden; scroll-margin-top: 6px; }
.stage {
  position: relative; isolation: isolate; overflow: hidden; height: clamp(460px, 59vh, 540px);
  background: radial-gradient(ellipse at 51% 45%, #292041 0%, #1c182e 39%, #141321 74%, #12121d 100%);
}
.stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, #b7a6f52b 1px, transparent 1.3px) 50% 50% / 21px 21px;
  opacity: .43; mask-image: radial-gradient(ellipse at 50% 38%, transparent 10%, #000 90%);
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(transparent 68%, #12121d60);
}
.stage-floor {
  position: absolute; pointer-events: none; z-index: -1; width: 180%; height: 73%; left: -40%;
  top: 52%; transform-origin: center top; transform: perspective(240px) rotateX(45deg);
  background: linear-gradient(#9a80de2d 1px, transparent 1px), linear-gradient(90deg, #9a80de30 1px, transparent 1px);
  background-size: 49px 33px; mask-image: radial-gradient(ellipse at 50% 57%, #000 10%, transparent 63%);
}
.stage-shadow {
  position: absolute; z-index: -1; left: 32%; right: 30%; top: 75%; height: 17%;
  pointer-events: none; background: radial-gradient(ellipse, #060410b8, transparent 72%); filter: blur(9px);
}
#cube-canvas { display: block; position: relative; width: 100%; height: 100%; touch-action: none; }
.stage-top, .stage-bottom {
  position: absolute; inset-inline: 18px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; pointer-events: none;
}
.stage-top { top: 17px; }
.stage-bottom { bottom: 16px; }
.stage-top button, .stage-top .segmented { pointer-events: auto; }
.segmented {
  display: inline-flex; align-items: stretch; gap: 3px; padding: 4px;
  background: #12111dcc; border: 1px solid #363049; border-radius: 9px;
}
.segmented button {
  padding: 0 .72rem; min-height: 34px; border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: #c7bfd8; font-size: .875rem; font-weight: 600; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { color: #ede3ff; background: #382a57; border-color: #62488e; }
.segmented button:not(:disabled):not([aria-pressed="true"]):hover { background: #262139; color: #f0e8fa; }
.size-options button { font-family: var(--mono); }
.camera-button { background: #161323dd; border-color: #373048; }
.gesture-hint { font-size: .875rem; color: #c6bdd8; display: inline-flex; align-items: center; gap: 6px; }
.gesture-icon { color: #bb9ff7; font-size: 1.05rem; }
.stage-foot-label { display: inline-flex; gap: 8px; color: #d7cdea; font: 600 .75rem/1 var(--mono); }
.view-axis {
  display: inline-grid; width: 21px; height: 21px; place-items: center; border: 1px solid #3b324f;
  border-radius: 5px; background: #1c172abf;
}
.view-axis-x { color: #ffa2ad; }
.view-axis-y { color: #a2e3bd; }
.view-axis-z { color: #bda6ff; }
.studio-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 16px; border-top: 1px solid var(--line); }
.primary-actions, .utility-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.action-button {
  min-height: 42px; padding: .45rem .85rem; display: inline-flex; align-items: center; justify-content: center;
  gap: .32rem; border: 1px solid transparent; border-radius: 8px; font-size: .875rem; font-weight: 680;
  line-height: 1.25; white-space: nowrap; transition: background .15s, border-color .15s;
}
.action-button.primary { background: var(--accent); color: var(--ink-on-accent); border-color: #c6afff; }
.action-button.primary:hover:not(:disabled) { background: #d2bcff; border-color: #e0ceff; }
.action-button.secondary { background: #201b30; color: #e3d5fa; border-color: #46395d; }
.action-button.secondary:hover:not(:disabled) { background: #302440; border-color: #765f9a; }
.utility-actions { gap: 5px; }
.console { align-self: stretch; min-height: 100%; }
.console-header {
  padding: 15px 18px; display: flex; align-items: center; gap: .65rem;
  min-height: 61px; border-bottom: 1px solid var(--line);
}
.console-symbol {
  display: inline-grid; place-items: center; width: 29px; height: 29px; border: 1px solid #4f3c72;
  border-radius: 7px; background: #2f2348; color: #d0b5ff; font: 500 17px/1 var(--mono);
}
.console-header h2 { font-size: 1.02rem; letter-spacing: .025em; font-weight: 730; }
.console-body { padding: 16px; }
.metrics { display: grid; grid-template-columns: 1.15fr 1fr; border: 1px solid #353047; background: #12111d; border-radius: 9px; }
.metrics > div { min-width: 0; padding: 12px 13px; display: grid; gap: 9px; }
.metrics > div + div { border-left: 1px solid #343048; }
.metric-label { color: var(--muted); font-size: .875rem; }
.state { display: flex; align-items: center; gap: 7px; font-size: .92rem; min-height: 25px; font-weight: 640; }
.state i { flex: none; width: 7px; height: 7px; border-radius: 100%; background: #c5a0ff; box-shadow: 0 0 9px #aa77f977; }
.state[data-state="solved"] i { background: #78e4ac; box-shadow: 0 0 9px #54d79466; }
.state[data-state="working"] i { background: #f7c77f; box-shadow: 0 0 9px #fcb66866; }
.step-count { font: 670 1.22rem/25px var(--mono); color: #e5d8fa; }
.slice-controls { padding-block: 20px; }
.console h3, .solution h3 { color: #f2ebfc; font-size: .94rem; line-height: 1.4; }
.slice-controls h3 { margin-bottom: 13px; }
.field-row { display: grid; align-items: center; grid-template-columns: 59px minmax(0, 1fr); gap: 9px; margin-block: 9px; }
.field-row > span { color: var(--muted); font-size: .875rem; }
.field-row .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.field-row .segmented button { min-width: 0; padding: 0; font: 600 .875rem/1 var(--mono); }
.direction-hint { text-align: right; font-size: .82rem; line-height: 1.45; color: var(--muted); margin-block: 9px 13px; }
.turn-buttons, .solution-actions { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.turn-buttons .action-button { min-width: 0; padding-inline: 4px; }
.solution { border-top: 1px solid var(--line); padding-top: 17px; }
.mobile-solution .solution { display: none; padding: 13px 15px; }
.mobile-solution .solution.has-plan { display: block; }
.solution-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.solution-progress { color: #d1bbff; font: 600 .8rem/1.1 var(--mono); white-space: nowrap; }
.solution-note { color: var(--muted); font-size: .875rem; line-height: 1.65; margin-top: 9px; }
.solution-moves {
  display: flex; gap: 5px; flex-wrap: wrap; max-height: 80px; overflow: auto; overscroll-behavior: contain;
  scrollbar-color: #665183 #1b1729; margin: 10px 0; padding: 7px; border: 1px solid #312a43;
  border-radius: 7px; background: #12101b;
}
.move-chip {
  min-width: 32px; padding: 4px; text-align: center; border: 1px solid #403453;
  border-radius: 4px; color: #c9badb; font: 600 .81rem/1.2 var(--mono);
}
.move-chip.completed { color: #a1d1b9; border-color: #304a44; background: #1a282a; }
.move-chip.next { color: #211438; background: #c2a9ff; border-color: #c2a9ff; }
.solution-actions button { min-width: 0; padding-inline: 5px; }
.tutorial { margin-top: 40px; scroll-margin-top: 24px; }
.tutorial-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.tutorial-heading h2 { font-size: clamp(1.63rem, 2.7vw, 2.1rem); letter-spacing: -.044em; }
.tutorial-heading p { font-size: 1rem; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.guide-card { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.4fr); overflow: hidden; }
.guide-summary { padding: 24px; background: radial-gradient(ellipse at 0 15%, #30214788, transparent 85%); }
.guide-method { color: #d1b8ff; font-size: .875rem; font-weight: 650; }
.guide-summary h3 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); margin-block: 7px 12px; line-height: 1.25; }
.guide-summary p, .guide-steps p { color: #c1b9cf; line-height: 1.7; font-size: 1rem; }
.guide-links { margin-top: 15px; display: flex; gap: 6px 13px; flex-wrap: wrap; }
.guide-links a { font-size: .875rem; color: #d2b8ff; text-decoration-color: #8462bd; text-underline-offset: 3px; }
.guide-links a:hover { color: #f4e9ff; }
.guide-steps { border-left: 1px solid var(--line); }
.guide-steps details + details { border-top: 1px solid var(--line); }
.guide-steps summary {
  display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center;
  list-style: none; cursor: pointer; min-height: 61px; padding: 12px 18px;
}
.guide-steps summary::-webkit-details-marker { display: none; }
.guide-steps summary:hover, .guide-steps details[open] summary { background: #211a32; }
.guide-steps summary::after { content: "+"; font: 500 1.2rem/1 var(--mono); color: var(--accent); }
.guide-steps details[open] summary::after { content: "−"; }
.phase-number {
  display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid #4c3b65;
  border-radius: 6px; background: #2b2140; color: var(--accent); font: 700 .81rem/1 var(--mono);
}
.guide-steps summary strong { font-size: .95rem; }
.phase-lead { display: block; color: var(--muted); font-size: .875rem; margin-top: 4px; line-height: 1.4; }
.phase-content { padding: 10px 20px 19px 59px; display: grid; gap: 9px; }
.phase-content code {
  justify-self: start; padding: 6px 9px; border-radius: 5px; background: #221a34;
  color: #e1caff; overflow-wrap: anywhere; font: 600 .88rem/1.5 var(--mono);
}
.guide-example {
  min-width: 0; margin: 3px 0 0; padding: 12px; border: 1px solid #3b304f; border-radius: 10px;
  background: #13111e;
}
.example-panels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 77px), 1fr)); gap: 8px;
}
.example-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 9px 4px 7px; min-width: 0; background: #1c172b; border-radius: 6px;
}
.example-grid {
  display: grid; grid-template-columns: repeat(var(--diagram-size), minmax(0, 1fr)); gap: 3px;
  width: min(100%, calc(var(--diagram-size) * 18px + 6px)); aspect-ratio: 1; padding: 3px;
  border-radius: 5px; background: #0e0d16;
}
.example-tile { background: #343042; border-radius: 2px; }
.example-tile[data-color="U"] { background: #f5f3e9; }
.example-tile[data-color="D"] { background: #f6d648; }
.example-tile[data-color="L"] { background: #ff9a4c; }
.example-tile[data-color="R"] { background: #f35063; }
.example-tile[data-color="F"] { background: #39cf86; }
.example-tile[data-color="B"] { background: #5b9afb; }
.example-tile[data-focus] { box-shadow: inset 0 0 0 1px #11101b, 0 0 0 1px #e2d1ff; }
.example-panel-label { color: #e8dcf8; font-size: .875rem; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.example-caption { margin-top: 9px; color: var(--muted); font-size: .875rem; line-height: 1.55; }
.footer {
  margin-top: 34px; padding-block: 19px 26px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; color: var(--muted); gap: 15px; font-size: .875rem;
}
.footer span { font-family: var(--mono); }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--accent); }
.shortcut-dialog {
  max-width: 510px; width: calc(100% - 32px); border: 1px solid #53456b; border-radius: var(--radius);
  padding: 20px; color: #f6efff; background: #1b1728;
}
.shortcut-dialog::backdrop { background: #0a0810bf; }
.shortcut-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shortcut-dialog h2 { font-size: 1.25rem; }
.close-button { min-width: 38px; padding: 0; font-size: 1.4rem; }
.shortcut-dialog dl { display: grid; gap: 13px; margin-block: 14px 4px; }
.shortcut-dialog dt { font-weight: 650; }
.shortcut-dialog dd { color: #c6bed5; margin: 5px 0 0; line-height: 1.7; font-size: .875rem; }
kbd { border: 1px solid #5a4a76; color: #ecddfc; background: #2c2240; border-radius: 4px; padding: 1px 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1100px) {
  .shell { width: calc(100% - 64px); }
  .workbench { grid-template-columns: minmax(0, 1fr) 298px; gap: 14px; }
}
@media (max-width: 870px) {
  .shell { width: calc(100% - 36px); }
  .workbench { grid-template-columns: minmax(0, 1fr) 282px; gap: 11px; }
  .studio-toolbar { flex-wrap: wrap; padding-inline: 12px; gap: 8px; }
  .stage { height: clamp(405px, 55vh, 500px); }
  .console-body { padding: 13px; }
}
@media (max-width: 730px) {
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .stage { height: clamp(362px, 100vw, 490px); }
  .lab-heading { padding-top: 28px; padding-bottom: 21px; }
  .topbar { height: 58px; }
  .tutorial { margin-top: 35px; }
  .guide-card { grid-template-columns: 1fr; }
  .guide-steps { border-left: 0; border-top: 1px solid var(--line); }
  .guide-summary { padding: 19px; }
  .solution-moves { max-height: 112px; }
}
@media (max-width: 420px) {
  .shell { width: calc(100% - 24px); }
  .brand { font-size: 16px; gap: 6px; }
  .brand-mark { width: 20px; height: 22px; }
  .shortcut-trigger { padding-inline: 9px; min-width: 35px; }
  .shortcut-text { display: none; }
  .stage-top, .stage-bottom { inset-inline: 10px; }
  .size-options button { padding-inline: .48rem; }
  .camera-button { min-height: 38px; padding-inline: 7px; font-size: .82rem; }
  .studio-toolbar { padding: 9px; }
  .primary-actions, .utility-actions { gap: 5px; }
  .studio-toolbar button { padding-inline: .48rem; }
  .gesture-hint { font-size: .82rem; }
  .tutorial-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .phase-content { padding-left: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}

.stage-foot-label .view-axis {
  pointer-events: auto;
  width: 25px;
  height: 25px;
  font: inherit;
}
.stage-foot-label .view-axis[aria-pressed="true"], .stage-foot-label .view-axis:hover:not(:disabled) {
  border-color: #8871ad;
  background: #322544;
}
.solution-moves { position: relative; }

/* Keep the portal return link next to the app’s shortcut control. */
.topbar-inner .shortcut-trigger { margin-inline-start: auto; }
