body { background: #f6f8fc; }
.lab-shell { max-width: 1430px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.back-link { color: #50617f; font-size: 13px; font-weight: 650; }
.back-link:hover, .breadcrumbs a:hover { color: #395bd4; }
.lab-main { padding: 28px 0 82px; }
.breadcrumbs { display: flex; gap: 9px; color: #9ba5b6; font-size: 12px; }
.breadcrumbs span:last-child { color: #56627a; }
.lab-intro { display: flex; justify-content: space-between; align-items: end; gap: 25px; padding: 38px 0 36px; }
.lab-intro h1 { margin: 21px 0 10px; font-size: clamp(37px, 4vw, 54px); }
.lab-intro h1 span { color: var(--blue); }
.lab-intro p { max-width: 750px; margin: 0; color: #6d778a; line-height: 1.85; font-size: 15px; }
.intro-badge { display: grid; gap: 9px; min-width: 160px; padding-bottom: 3px; color: #697995; font-size: 11px; white-space: nowrap; }
.intro-badge span { padding-left: 12px; border-left: 2px solid #9eb2ed; }
.panel { border: 1px solid #e1e6ef; border-radius: 17px; background: #fff; box-shadow: 0 6px 24px rgba(25,48,88,.035); }
.input-panel { padding: 24px 27px 23px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-bottom: 17px; }
.panel-number { display: block; margin-bottom: 6px; color: #627ce4; font-size: 10px; letter-spacing: .15em; font-weight: 820; }
.panel-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.input-hint { color: #8893a5; font-size: 11px; text-align: right; }
.expression-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.expression-form input { min-width: 0; height: 55px; padding: 0 18px; border: 1px solid #d9e0eb; border-radius: 11px; outline: none; color: #243861; background: #fbfcff; font: 650 20px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .025em; transition: border-color .2s, box-shadow .2s; }
.expression-form input:focus { border-color: #6882e5; box-shadow: 0 0 0 4px #dfe6ff; }
.action-button { min-width: 137px; padding: 0 19px; border: 0; border-radius: 11px; color: #fff; background: #3c5ed9; font-size: 14px; font-weight: 760; cursor: pointer; transition: background .2s, transform .2s; }
.action-button:hover { background: #294bc4; transform: translateY(-1px); }
.action-button span { margin-left: 8px; }
.input-help { margin: 12px 0 17px; color: #8791a2; font-size: 11px; line-height: 1.65; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.examples-label { margin-right: 3px; color: #8791a3; font-size: 11px; }
.example-chip { padding: 7px 10px; border: 1px solid #e3e8f1; border-radius: 8px; color: #5d6b82; background: #f8fafd; font: 650 12px ui-monospace, Consolas, monospace; cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.example-chip:hover { color: #3156cd; border-color: #b7c7f3; background: #eef2ff; }
.example-chip small { margin-left: 8px; color: #96a0b1; font: 500 10px Inter, "Microsoft YaHei", sans-serif; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(285px, .9fr); align-items: stretch; gap: 18px; margin-top: 18px; }
.visual-column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.phase-panel { padding: 24px 26px 27px; }
.panel-heading.compact { margin-bottom: 20px; }
.step-counter { padding: 7px 10px; border-radius: 8px; color: #5268aa; background: #edf2ff; font-size: 11px; font-weight: 750; white-space: nowrap; }
.phase-track { display: flex; align-items: center; margin-bottom: 25px; }
.phase-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: #9aa4b4; font-size: 11px; font-weight: 750; }
.phase-item b { font-weight: 750; }
.phase-item.active { color: #3d5ed6; }
.phase-item.complete { color: #26835c; }
.phase-line { flex: 1; height: 1px; margin: 0 13px; background: #dfe5ef; }
.visual-label-row { display: flex; justify-content: space-between; gap: 10px; color: #68768d; font-size: 11px; font-weight: 740; }
.visual-label-row span:last-child { color: #a4adbb; font-weight: 500; text-align: right; }
.token-stream { display: flex; flex-wrap: wrap; gap: 7px; min-height: 64px; margin-top: 11px; padding: 12px; border: 1px solid #e6ebf3; border-radius: 11px; background: #f8faff; }
.token { position: relative; display: grid; place-items: center; min-width: 39px; height: 39px; padding: 0 11px; border: 1px solid transparent; border-radius: 8px; font: 700 15px ui-monospace, Consolas, monospace; transition: transform .2s, border-color .2s, box-shadow .2s; }
.token.number { color: #3756a3; background: #e9efff; }
.token.operator { color: #ba682f; background: #fff0e0; }
.token.bracket { color: #8065a9; background: #f2eaff; }
.token.active { transform: translateY(-2px); border-color: #526fe5; box-shadow: 0 4px 11px #ccd7fa; }
.token-empty { align-self: center; color: #9aa4b4; font-size: 12px; }
.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.data-panel { min-height: 170px; padding: 21px 22px 17px; }
.data-panel.wide { grid-column: span 2; min-height: 145px; }
.data-panel.focus { border-color: #9fb3f6; box-shadow: 0 0 0 3px #e9efff; }
.data-heading { display: flex; align-items: center; gap: 11px; }
.data-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 auto; border-radius: 9px; font-size: 18px; font-weight: 700; }
.operator-icon { color: #ad693f; background: #fff0e4; }
.postfix-icon { color: #3d62c3; background: #eaf0ff; }
.value-icon { color: #25805d; background: #e6f7ef; }
.data-heading h3 { margin: 0 0 2px; font-size: 14px; }
.data-heading p { margin: 0; color: #a0a9b8; font-size: 10px; }
.chip-lane { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 45px; margin-top: 16px; }
.stack-chip { display: grid; place-items: center; min-width: 34px; height: 33px; padding: 0 8px; border-radius: 7px; font: 700 12px ui-monospace, Consolas, monospace; animation: chip-in .22s ease-out; }
.stack-chip.operator { color: #a85e2a; background: #fff0e2; }
.stack-chip.output { color: #3c59aa; background: #e9efff; }
.stack-chip.value { color: #257855; background: #e3f6ea; }
.stack-chip.active { outline: 2px solid #516ed9; outline-offset: 2px; }
.stack-empty { color: #a4adba; font-size: 11px; }
.stack-direction { margin-top: 9px; color: #a8b1be; font-size: 10px; }
.stack-direction span { padding: 0 3px; }
@keyframes chip-in { from { opacity: .4; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.explanation-panel { min-height: 545px; padding: 26px; display: flex; flex-direction: column; }
.explanation-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #9aa5b4; font: 730 11px ui-monospace, Consolas, monospace; }
.stage-label { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 7px; color: #3a5bcc; background: #edf1ff; font: 700 11px Inter, "Microsoft YaHei", sans-serif; }
.stage-label.evaluate { color: #147c5a; background: #e8f7f0; }
.stage-label.error { color: #b64e43; background: #fff0ed; }
.explanation-panel h2 { margin: 25px 0 12px; font-size: 23px; line-height: 1.35; letter-spacing: -.03em; }
.explanation-panel > p { min-height: 67px; margin: 0; color: #69758a; font-size: 13px; line-height: 1.85; }
.calculation-box, .result-box { margin-top: 19px; padding: 13px 16px; border-radius: 10px; }
.calculation-box { color: #365593; background: #eef3ff; }
.calculation-box span, .result-box span { display: block; margin-bottom: 5px; font-size: 10px; font-weight: 750; letter-spacing: .06em; }
.calculation-box strong { display: block; overflow-wrap: anywhere; font: 750 18px ui-monospace, Consolas, monospace; }
.result-box { color: #1d7655; background: #e8f8ef; }
.result-box.error { color: #b2453c; background: #fff0ed; }
.result-box strong { display: block; overflow-wrap: anywhere; font: 800 22px ui-monospace, Consolas, monospace; }
.code-heading { display: flex; justify-content: space-between; margin-top: auto; padding-top: 28px; color: #59677f; font-size: 11px; font-weight: 760; }
.code-heading span:last-child { color: #a3acba; font-weight: 500; }
.code-lines { margin: 12px 0 0; padding: 14px 0; list-style: none; border: 1px solid #e6eaf2; border-radius: 9px; background: #f8fafd; }
.code-lines li { display: grid; grid-template-columns: 23px 1fr; gap: 7px; padding: 5px 13px; color: #78859c; font: 500 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.code-lines li.active { color: #3155c7; background: #e9efff; font-weight: 750; }
.code-lines li span:first-child { color: #adb7c7; user-select: none; }

.controls-panel { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; padding: 17px 20px; }
.control-buttons { display: flex; gap: 7px; flex-wrap: wrap; }
.control-button { height: 37px; padding: 0 12px; border: 1px solid #dce3ee; border-radius: 8px; color: #475875; background: #fff; font-size: 11px; font-weight: 730; cursor: pointer; }
.control-button:hover:not(:disabled) { border-color: #9aafea; color: #3154bd; }
.control-button:disabled { opacity: .43; cursor: not-allowed; }
.primary-control { border-color: #3c5ed9; color: #fff; background: #3c5ed9; }
.primary-control:hover:not(:disabled) { border-color: #294bc4; color: #fff; background: #294bc4; }
.quiet-control { border-color: transparent; color: #8290a5; }
.timeline { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; }
.timeline input[type=range] { flex: 1; min-width: 110px; accent-color: #4565df; }
.speed-label { color: #8490a2; font-size: 10px; white-space: nowrap; }
.timeline select { min-width: 65px; padding: 6px 4px; border: 1px solid #dce3ee; border-radius: 7px; color: #59677d; background: #fff; font-size: 11px; }
.keyboard-hint { margin: 0; color: #a2acba; font-size: 10px; }
.source-panel { display: flex; align-items: end; justify-content: space-between; gap: 25px; padding: 43px 3px 0; }
.source-panel h2 { margin: 7px 0 10px; font-size: 26px; }
.source-panel p { max-width: 750px; margin: 0; color: #758196; font-size: 12px; line-height: 1.85; }
.source-link { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 13px; padding: 12px 16px; border: 1px solid #cdd8f6; border-radius: 9px; color: #3b5bbf; background: #eef2ff; font-size: 12px; font-weight: 740; }
.source-link:hover { background: #e1e9ff; }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr; }
  .explanation-panel { min-height: auto; }
  .code-heading { margin-top: 10px; }
}
@media (max-width: 650px) {
  .lab-main { padding-top: 20px; }
  .lab-intro { padding: 30px 0 27px; }
  .lab-intro h1 { font-size: 39px; }
  .lab-intro p { font-size: 13px; }
  .intro-badge { display: none; }
  .input-panel, .phase-panel, .explanation-panel { padding: 19px; }
  .input-hint { display: none; }
  .expression-form { grid-template-columns: 1fr; }
  .expression-form input { height: 51px; font-size: 18px; }
  .action-button { min-height: 43px; }
  .data-grid { grid-template-columns: 1fr; gap: 12px; }
  .data-panel, .data-panel.wide { grid-column: auto; min-height: 134px; padding: 17px 19px; }
  .phase-item { font-size: 10px; }
  .phase-line { margin: 0 8px; }
  .controls-panel { padding: 15px; }
  .control-buttons { width: 100%; }
  .control-button { flex: 1 1 auto; }
  .control-button span { font-size: 10px; }
  .source-panel { align-items: start; flex-direction: column; }
  .back-link { font-size: 11px; }
}
