/* 哈珀编程：样式。版式和色调完全按「哈珀官方界面标准」（以哈珀学英语为准：白色 + 靛紫哈珀色调 + 衬线大标题 + 胶囊导航 + 大圆角卡片），
   通用组件在 /static/harper-official.css（ho-*），页面 <html data-ui="official"> 后旧的 --hc-* 令牌自动换成官方值；这里只写哈珀编程自己的页面。
   颜色一律引用令牌，不写死。手机优先，≥ 768 平板、≥ 1200 电脑。 */
body { background: var(--hc-bg); color: var(--hc-text); min-height: 100%; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ── 版心 ── */
.cd-main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; min-height: 70vh; }
.cd-h1 { font: 800 30px/1.25 var(--ho-serif); margin: 10px 0 6px; }
.cd-sub { color: var(--hc-muted); margin: 0 0 14px; }
.cd-member-tip { max-width: 100%; min-width: 0; line-height: 1.8; overflow-wrap: anywhere; word-break: break-word; }
html[lang="en"] .cd-member-tip, html[lang="id"] .cd-member-tip, html[lang="vi"] .cd-member-tip { margin: 0; padding: 14px 16px; }
.cd-member-tip a { overflow-wrap: anywhere; word-break: break-word; }
.cd-card { background: var(--hc-surface); border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); box-shadow: var(--hc-shadow); min-width: 0; }
.cd-empty { padding: 36px 16px; text-align: center; color: var(--hc-muted); }
.cd-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--hc-brand-soft); color: var(--hc-brand); }
.cd-tag.ok { background: var(--ho-ok-bg); color: var(--hc-ok); } .cd-tag.warn { background: var(--ho-warn-bg); color: var(--hc-warn); }
.cd-notice { padding: 14px 16px; margin-bottom: 12px; color: var(--hc-muted); }
.cd-link { background: none; border: 0; padding: 6px 2px; font-weight: 700; color: var(--hc-text); }
.cd-link:hover { color: var(--hc-brand); }

/* ── 按钮：胶囊形，主按钮靛紫，次按钮白底描边 ── */
.cd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 20px; border-radius: 999px; border: 1px solid var(--hc-brand); background: var(--hc-brand); color: var(--hc-on-brand); font-weight: 700; box-shadow: var(--ho-shadow-btn); }
.cd-btn:hover { background: var(--hc-brand-strong); }
.cd-btn.ghost { background: var(--ho-panel); color: var(--hc-text); border-color: var(--hc-border); box-shadow: none; }
.cd-btn.ghost:hover { border-color: var(--hc-brand); color: var(--hc-brand); background: var(--ho-panel); }
.cd-btn.sm { min-height: 34px; padding: 4px 14px; font-size: 13px; }
.cd-btn.lg { min-height: 48px; padding: 0 28px; font-size: 15px; }
.cd-btn:disabled { opacity: .5; cursor: not-allowed; }
.cd-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 36px; border-radius: 12px; border: 1px solid var(--hc-border); background: var(--ho-panel); cursor: pointer; padding: 0; }
.cd-ico:hover { border-color: var(--hc-brand); }
.cd-ico.flag { color: var(--hc-ok); } .cd-ico.stop { color: var(--hc-err); }
.cd-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--hc-border); border-radius: 999px; background: var(--ho-soft); }
.cd-seg button { border: 0; background: transparent; color: var(--hc-muted); padding: 6px 14px; font-size: 13px; font-weight: 700; border-radius: 999px; }
.cd-seg button.on { background: var(--ho-panel); color: var(--hc-text); box-shadow: var(--ho-shadow-seg); }
.cd-tabs { display: flex; gap: 4px; margin: 22px 0 12px; overflow-x: auto; border-bottom: 1px solid var(--hc-border); }
.cd-tabs button { border: 0; background: transparent; padding: 10px 16px; font-weight: 700; color: var(--hc-muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.cd-tabs button.on { color: var(--hc-brand); border-bottom-color: var(--hc-brand); }
.cd-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cd-filter > span { color: var(--hc-muted); width: 44px; flex: none; }
.cd-chip { border: 1px solid var(--hc-border); background: var(--ho-panel); border-radius: 999px; padding: 4px 14px; font-size: 14px; }
.cd-chip.on { background: var(--hc-brand); border-color: var(--hc-brand); color: var(--hc-on-brand); font-weight: 700; }
.cd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.cd-stats b { display: block; font: 800 22px var(--ho-serif); } .cd-stats span { font-size: 12px; color: var(--hc-muted); }

/* ── 首页：演示卡里的「编程界面 + 运行结果」（纯 CSS 动画：小猫沿舞台走，头顶冒气泡）── */
.cd-mock { position: relative; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; display: grid; grid-template-columns: 44% 56%; background: var(--ho-grad-demo); padding: 10px; gap: 10px; }
.cd-mock .ho-badge { left: 18px; top: auto; bottom: 16px; z-index: 3; }
.cd-mock-code { background: var(--ho-panel); border-radius: 12px; padding: 12px 10px; display: flex; flex-direction: column; gap: 5px; overflow: hidden; }
.cd-mock-code i { font-style: normal; font: 700 12px/1 var(--ho-sans); padding: 8px 10px; border-radius: 7px; color: var(--ho-panel); width: max-content; max-width: 100%; box-shadow: 0 2px 0 var(--ho-scrim); }
.cd-mock-code .ev { background: var(--ho-blk-event); border-radius: 12px 12px 7px 7px; } .cd-mock-code .ct { background: var(--ho-blk-ctl); } .cd-mock-code .mo { background: var(--ho-blk-motion); margin-left: 14px; } .cd-mock-code .lk { background: var(--ho-blk-looks); margin-left: 14px; }
.cd-mock-stage { position: relative; border-radius: 12px; background: linear-gradient(var(--ho-stage-sky) 0 68%, var(--ho-stage-grass) 68%); overflow: hidden; }
.cd-cat { position: absolute; bottom: 14%; left: 8%; font-size: clamp(30px, 4.4vw, 52px); animation: cdWalk 4s ease-in-out infinite alternate; }
.cd-bubble { position: absolute; top: 12%; left: 12%; padding: 4px 10px; border-radius: 12px; background: var(--ho-panel); font: 700 13px var(--ho-sans); box-shadow: 0 4px 12px var(--ho-scrim); animation: cdSay 4s ease-in-out infinite alternate; }
@keyframes cdWalk { from { transform: translateX(0) scaleX(1); } 49% { transform: translateX(150%) scaleX(1); } 51% { transform: translateX(150%) scaleX(-1); } to { transform: translateX(0) scaleX(-1); } }
@keyframes cdSay { from { transform: translateX(0); } to { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .cd-cat, .cd-bubble { animation: none; } }

/* ── 课程 / 课时 ── */
.cd-course-head { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 18px; margin-bottom: 14px; }
.cd-cover { height: 92px; display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--hc-on-brand); border-radius: var(--hc-radius); }
.dir-scratch { background: var(--ho-grad-brand); } .dir-python { background: var(--ho-grad-sky); } .dir-cpp { background: var(--ho-grad-violet); }
.dir-javascript, .ho-thumb.dir-javascript { background: linear-gradient(135deg, var(--ho-warn), var(--ho-warn-line)); }          /* JavaScript：琥珀色 */
.cd-course-head .cd-cover { height: 140px; font-size: 56px; }
.cd-lessons { list-style: none; margin: 0; padding: 0; }
.cd-lessons li a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--hc-border); min-height: 48px; }
.cd-lessons li:first-child a { border-top: 0; }
.cd-lessons li a:hover { background: var(--hc-brand-soft); }
.cd-no { width: 28px; height: 28px; border-radius: 50%; background: var(--hc-brand-soft); color: var(--hc-brand); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex: none; }
.cd-lessons .grow { flex: 1; min-width: 0; }
.cd-body { white-space: pre-wrap; line-height: 1.9; padding: 20px 22px; font-size: 16px; }
.cd-code { white-space: pre; overflow: auto; font: 14px/1.7 Consolas, Menlo, "Courier New", monospace; background: var(--ho-bg); border: 1px solid var(--hc-border); border-radius: var(--hc-radius); padding: 14px; margin: 0; }
.cd-video { width: 100%; max-height: 60vh; background: var(--ho-ink); border-radius: var(--hc-radius); }
.cd-pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* ── 编程大闯关 ── */
.cd-world { margin-bottom: 18px; padding: 16px 18px; }
.cd-world h3 { margin: 0 0 12px; font: 800 18px var(--ho-serif); }
.cd-nodes { display: flex; flex-wrap: wrap; gap: 14px; }
.cd-node { width: 92px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.cd-node i { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 800; font-size: 20px; background: var(--ho-soft-2); border: 3px solid var(--hc-border); }
.cd-node.done i { background: var(--hc-brand); border-color: var(--ho-dash); color: var(--hc-on-brand); }
.cd-node small { font-size: 12px; color: var(--hc-muted); line-height: 1.3; }
.cd-stars { color: var(--ho-star); letter-spacing: 1px; font-size: 13px; }
.cd-play { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.cd-zone { min-height: 56px; border: 1px dashed var(--ho-dash); background: var(--ho-input-bg); border-radius: var(--hc-radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cd-zone > small { color: var(--hc-faint); }
.cd-block { text-align: left; border: 1px solid var(--hc-brand); background: var(--hc-brand); color: var(--hc-on-brand); border-radius: 12px; padding: 10px 14px; min-height: 44px; font: 15px/1.4 Consolas, Menlo, "Microsoft YaHei", monospace; white-space: pre; }
.cd-block.pick { background: var(--ho-panel); border-color: var(--hc-border); color: var(--hc-text); }
.cd-opt { text-align: left; border: 1px solid var(--hc-border); background: var(--ho-panel); border-radius: 12px; padding: 12px 14px; min-height: 48px; }
.cd-opt.on { border-color: var(--hc-brand); background: var(--hc-brand-soft); box-shadow: 0 0 0 2px var(--hc-brand-line); }
.cd-result { padding: 12px 14px; border-radius: var(--hc-radius); border: 1px solid var(--hc-border); }
.cd-result.ok { background: var(--ho-ok-bg); color: var(--hc-ok); border-color: var(--ho-ok-line); } .cd-result.bad { background: var(--ho-err-bg); color: var(--hc-err); border-color: var(--ho-err-line); }

/* ── 作品 / 表单 ── */
.cd-work-top { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 18px; }
.cd-form { padding: 18px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.cd-form label { font-size: 13px; color: var(--hc-muted); font-weight: 600; }
.cd-form input, .cd-form textarea, .cd-form select, .cd-dialog input { width: 100%; font: inherit; font-size: 15px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); color: var(--hc-text); }
.cd-form textarea { min-height: 200px; font-family: Consolas, Menlo, "Courier New", monospace; font-size: 14px; }
.cd-form input:focus, .cd-form textarea:focus, .cd-dialog input:focus { outline: 0; border-color: var(--ho-brand-2); box-shadow: var(--ho-ring); }
.cd-msg { min-height: 20px; color: var(--hc-err); font-size: 14px; }

/* ── 弹窗 / 提示 / 页脚 ── */
.cd-modal { position: fixed; inset: 0; z-index: 80; background: var(--ho-scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.cd-dialog { width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--ho-panel); border-radius: 24px; padding: 24px; box-shadow: var(--ho-shadow-pop); display: flex; flex-direction: column; gap: 10px; }
.cd-dialog h3 { margin: 0 0 4px; font: 800 20px var(--ho-serif); }
.cd-dialog label { font-size: 13px; color: var(--hc-muted); font-weight: 600; }
.cd-dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.cd-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; background: var(--ho-dark); color: var(--ho-panel); padding: 10px 20px; border-radius: 999px; box-shadow: var(--ho-shadow-pop); font-weight: 700; font-size: 14px; }
.cd-foot { padding: 30px 16px calc(40px + env(safe-area-inset-bottom)); text-align: center; color: var(--hc-faint); font-size: 12.5px; }
.cd-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (min-width: 768px) { .cd-course-head { grid-template-columns: 220px 1fr; } }

/* ── Scratch 程序：舞台播放器（沙箱 iframe）+ 完整 Scratch 编辑器（同源 iframe）+ 两种全屏 ── */
.cd-player { background: var(--ho-panel); border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); padding: 14px; box-shadow: var(--hc-shadow); max-width: 680px; }
.cd-player-bar { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-bottom: 12px; container-type: inline-size; }          /* 工具条始终一行：按钮默认只留线性图标（鼠标放上去有提示），特别宽时才显示文字；放不下时先藏程序信息 */
.cd-player-bar > * { flex: none; }
.cd-player-bar .cd-seg button { padding: 5px 11px; font-size: 12.5px; }                                                               /* 标签压紧一点 */
.cd-player-bar .cd-btn { white-space: nowrap; padding: 6px 10px; }
.cd-player-bar .cd-btn .lbl { display: none; }
.cd-player-bar .cd-player-info { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
@container (max-width: 1280px) { .cd-player-bar .cd-player-info { display: none; } }
@container (min-width: 1600px) { .cd-player-bar .cd-btn .lbl { display: inline; } .cd-player-bar .cd-btn { padding: 6px 12px; } }
@media (max-width: 899px) { .cd-player-bar { flex-wrap: wrap; } }                                                                     /* 手机上也保持纯图标；文字不再强制显示，改成点一下悬浮提示（.cd-tip，逻辑在 coding.js） */
.cd-tip { display: none; position: fixed; z-index: 9999; max-width: 240px; padding: 6px 10px; border-radius: 10px; background: var(--hc-text); color: var(--ho-panel); font-size: 12.5px; line-height: 1.45; box-shadow: var(--hc-shadow); pointer-events: none; }
.cd-player-stage { position: relative; width: 100%; aspect-ratio: 4 / 3; background: var(--ho-bg); border: 1px solid var(--hc-border); border-radius: var(--hc-radius); overflow: hidden; }
.cd-player-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cd-player-stage:fullscreen, .cd-player-stage.cd-pseudo-full { aspect-ratio: auto; border: 0; border-radius: 0; }
.cd-player-stage.cd-pseudo-full, .cd-ide.cd-pseudo-full, .cd-code-stage.cd-pseudo-full { position: fixed; inset: 0; z-index: 9997; width: 100vw; height: 100vh; max-width: none; max-height: none; flex: none; }   /* 假全屏：浏览器不让用真正的 Fullscreen API 时退回这个（比如嵌在别的页面 iframe 里）；.cd-code-stage 平时有 max-width:480px（和 flex 的子项限制），不盖掉的话 position:fixed 也会被这个 480px 卡住，宽屏（平板）上只占一小块 */
.cd-player-tip { margin-top: 10px; font-size: 13px; color: var(--hc-muted); }
.cd-ide { position: relative; width: 100%; height: clamp(560px, 78vh, 860px); border: 1px solid var(--hc-border); border-radius: var(--hc-radius); overflow: hidden; background: var(--ho-panel); }
.cd-ide iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cd-ide:fullscreen, .cd-ide.cd-pseudo-full { height: 100vh; border: 0; border-radius: 0; }
.cd-player[data-view="run"] .cd-ide, .cd-player[data-view="ide"] .cd-player-stage, .cd-player[data-view="json"] .cd-ide, .cd-player[data-view="json"] .cd-player-stage,
.cd-player[data-view="js"] .cd-ide, .cd-player[data-view="js"] .cd-player-stage, .cd-player[data-view="py"] .cd-ide, .cd-player[data-view="py"] .cd-player-stage { display: none; }
.cd-json, .cd-cv { display: none; }
.cd-player[data-view="json"] .cd-json, .cd-player[data-view="js"] .cd-cv[data-pane="js"], .cd-player[data-view="py"] .cd-cv[data-pane="py"] { display: block; }
.cd-player[data-view="json"], .cd-player[data-view="js"], .cd-player[data-view="py"] { max-width: none; }
.cd-player[data-view="json"] [data-only="ide"], .cd-player[data-view="js"] [data-only="ide"], .cd-player[data-view="py"] [data-only="ide"] { display: none; }
.cd-langsel { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--hc-muted); }
.cd-lang { padding: 6px 28px 6px 12px; border: 1px solid var(--hc-border); border-radius: 999px; background: var(--ho-panel); color: var(--hc-text); font: 700 13px var(--ho-sans); cursor: pointer; }
.cd-lang:focus-visible { outline: 2px solid var(--hc-brand); outline-offset: 1px; }
.cd-code-main { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; justify-content: center; }   /* 平板宽度常见：代码区挤不下、换到舞台下面一行，舞台自己单独占一行时不设这条会贴在最左边，右边一大片空白 */
.cd-code-stage { flex: 1 1 340px; max-width: 480px; min-width: 0; }
.cd-code-ed { flex: 2 1 340px; min-width: 0; }
.cd-code-stage iframe { display: block; width: 100%; aspect-ratio: 480 / 440; border: 1px solid var(--hc-border); border-radius: var(--hc-radius); background: var(--ho-panel); }
/* 「隐藏到侧边栏」：代码区收起来，画板占满整行；右缘留一条竖向「代码」细条，点它展开（代码内容不动） */
.cd-code-main.code-off .cd-code-ed { display: none; }
.cd-code-main.code-off .cd-code-stage { max-width: none; }
.cd-code-peek { display: none; flex: none; align-self: stretch; align-items: center; justify-content: center; gap: 8px; width: 34px; padding: 12px 0; border: 1px solid var(--hc-border); border-radius: var(--hc-radius); background: var(--ho-soft-2); color: var(--ho-muted); font: 700 13px var(--ho-sans); writing-mode: vertical-rl; cursor: pointer; }
.cd-code-peek:hover, .cd-code-peek:focus-visible { color: var(--ho-brand); background: var(--ho-brand-soft); }
.cd-code-peek .hi { width: 15px; height: 15px; }
.cd-code-main.code-off .cd-code-peek { display: inline-flex; margin-left: auto; }          /* 细条贴右缘（画板没吃满时也不留空） */
.cd-json-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
@media (max-width: 899px) { .cd-json-bar .cd-btn .lbl { display: none; } .cd-json-bar .cd-btn { padding: 6px 10px; } }   /* 手机上这一排按钮太多，文字都收起来只留图标，点一下有悬浮提示（和舞台工具条一样） */
.cd-json-msg { font-size: 13px; color: var(--hc-muted); flex: 1 1 100%; order: 99; margin: 0; min-width: 0; overflow-wrap: anywhere; }          /* 提示单独占一行：不会把一排按钮撑得上下留白 */
.cd-json-msg.bad { color: var(--hc-err); font-weight: 700; }
.cd-cv.cd-jswork { display: block; margin-top: 14px; }                                                  /* 作品页的 JavaScript 作品：和「JavaScript」标签同一套代码框样式，但一直显示 */
.cd-json .cb, .cd-cv .cb { display: grid; grid-template-columns: auto minmax(0, 1fr); max-height: clamp(420px, 68vh, 760px); overflow: auto; }              /* 很长的 JSON / Python：框最高 68% 屏高，超出在框里滚动（行号跟着滚）；用 grid 而不是 flex：行号栏要和整段代码一样高，不能只有可见区域那么高，否则往下滚后行号栏的底色会断掉、代码会钻到行号下面 */
.cd-json .cb-body, .cd-cv .cb-body { overflow: visible; }
.cd-json .cb-gut, .cd-cv .cb-gut { position: sticky; left: 0; z-index: 1; }
.cd-json .cb-hl, .cd-json .cb-ta, .cd-cv .cb-hl, .cd-cv .cb-ta { font-size: 13px; line-height: 1.65; }
.cd-player[data-view="ide"] { max-width: none; }
.cd-player[data-view="run"] [data-only="ide"] { display: none; }
.cd-fs-ctl { display: none; position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 18px; background: var(--ho-scrim-dark); box-shadow: var(--ho-shadow-pop); }
.cd-fs-ctl .cd-ico { width: 46px; height: 42px; }
.cd-player-stage:fullscreen .cd-fs-ctl, .cd-player-stage.cd-pseudo-full .cd-fs-ctl, .cd-code-stage:fullscreen .cd-fs-ctl, .cd-code-stage.cd-pseudo-full .cd-fs-ctl,
.cd-ide:fullscreen .cd-fs-ide, .cd-ide.cd-pseudo-full .cd-fs-ide { display: flex; }
.cd-ide:fullscreen .cd-fs-ide, .cd-ide.cd-pseudo-full .cd-fs-ide { left: auto; right: 14px; bottom: 14px; transform: none; padding: 6px; }
html.cd-pseudo-full-lock, html.cd-pseudo-full-lock body { overflow: hidden; height: 100%; }   /* 假全屏铺满视口时，背后的页面不能再滚动 */
@media (max-width: 899px) { .cd-ide { height: 70vh; } }

/* 虚拟方向键 + 空格（俄罗斯方块这类靠键盘玩的作品，手机上没有物理键盘；电脑上也可以用鼠标点）：叠在舞台左下 / 右下角，半透明，不挡视线中间 */
.cd-vkey { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.cd-vkey[hidden] { display: none; }
.cd-vkey-dpad { position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: 126px; height: 126px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 4px; pointer-events: auto; }
.cd-vkey-btn { display: flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; padding: 0; background: var(--ho-scrim-dark); color: var(--ho-on-dark); touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; }
.cd-vkey-btn svg { width: 20px; height: 20px; }
.cd-vkey-btn.on { background: var(--hc-brand); }
.cd-vkey-dpad .vk-up { grid-area: 1 / 2; } .cd-vkey-dpad .vk-left { grid-area: 2 / 1; } .cd-vkey-dpad .vk-right { grid-area: 2 / 3; } .cd-vkey-dpad .vk-down { grid-area: 3 / 2; }
.cd-vkey-dpad .vk-down svg { transform: rotate(180deg); } .cd-vkey-dpad .vk-left svg { transform: rotate(-90deg); } .cd-vkey-dpad .vk-right svg { transform: rotate(90deg); }
.cd-vkey-space { position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%; font: 700 11px var(--ho-sans); pointer-events: auto; }
/* 全屏时下方还有一排运行/停止/退出全屏按钮（.cd-fs-ctl，自己 bottom:20px），方向键/空格键不让开会和它叠在一起。
   --cd-fs-bar-h 是 coding.js 用 ResizeObserver 实时量出来的 .cd-fs-ctl 真实高度（挂在舞台自己身上），这里用 calc() 引用，
   那排按钮以后增删、换行高度变了，这两个也会跟着自动调整，不用再手动对数字；fallback 58px 只在 JS 还没来得及量之前兜底一下 */
.cd-player-stage:fullscreen .cd-vkey-dpad, .cd-player-stage.cd-pseudo-full .cd-vkey-dpad, .cd-code-stage:fullscreen .cd-vkey-dpad, .cd-code-stage.cd-pseudo-full .cd-vkey-dpad {
  bottom: calc(20px + var(--cd-fs-bar-h, 58px) + 18px + env(safe-area-inset-bottom));
}
.cd-player-stage:fullscreen .cd-vkey-space, .cd-player-stage.cd-pseudo-full .cd-vkey-space, .cd-code-stage:fullscreen .cd-vkey-space, .cd-code-stage.cd-pseudo-full .cd-vkey-space {
  bottom: calc(20px + var(--cd-fs-bar-h, 58px) + 18px + env(safe-area-inset-bottom));
}

/* JS / Python 标签的小画板也能全屏（和 Scratch 舞台「运行全屏」一样，手机上更方便玩） */
.cd-code-stage { position: relative; }
.cd-code-stage:fullscreen, .cd-code-stage.cd-pseudo-full { display: flex; align-items: center; justify-content: center; background: var(--ho-ink); }
.cd-code-stage:fullscreen iframe, .cd-code-stage.cd-pseudo-full iframe { width: auto; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: 480 / 360; border: 0; }

/* 编程大闯关：地图 + 交互式任务页 */
.cd-world-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cd-task { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 8px; }
.cd-task-panel { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; padding: 18px; margin: 0; }
.cd-task-ide { min-width: 0; }
.cd-task-ide .cd-player { max-width: none; }
.cd-sidebtn { display: none; color: var(--hc-muted); }
.cd-task .cd-sidebtn { display: inline-flex; }
.cd-task.side-off .cd-sidebtn { color: var(--hc-brand); border-color: var(--hc-brand); background: var(--hc-brand-soft); }
.cd-task.side-off { grid-template-columns: minmax(0, 1fr); }
.cd-task.side-off .cd-task-panel { display: none; }
.cd-goal { margin: 0 0 8px; font-size: 15px; line-height: 1.7; }
.cd-tipline { margin: 0 0 10px; }
.cd-steps { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cd-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--hc-border); border-radius: var(--hc-radius); background: var(--ho-panel); }
.cd-steps li.cur { border-color: var(--hc-brand); background: var(--hc-brand-soft); }
.cd-steps li.ok { opacity: .75; }
.cd-sno { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; background: var(--ho-soft-2); color: var(--hc-muted); }
.cd-steps li.cur .cd-sno { background: var(--hc-brand); color: var(--hc-on-brand); }
.cd-steps li.ok .cd-sno { background: var(--hc-ok); color: var(--hc-on-brand); }
.cd-stext { font-size: 14px; line-height: 1.65; }
.cd-hints { margin-top: 8px; }
.cd-hints p { margin: 0 0 6px; font-size: 13px; line-height: 1.6; padding: 8px 10px; border-radius: 10px; background: var(--ho-warn-bg); color: var(--ho-warn); }
.cd-runbox { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin: 12px 0; }
.cd-checks { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.cd-checks li.ok { color: var(--hc-ok); }
.cd-checks li.bad { color: var(--hc-err); font-weight: 700; }
.cd-task-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.cd-starrule { margin: 10px 0 0; font-size: 12px; }
@media (max-width: 1000px) { .cd-task { grid-template-columns: minmax(0, 1fr); } .cd-task-panel { position: static; max-height: none; } }


.cd-note { margin: 10px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.65; }
.cd-note.ok { background: var(--ho-teal-bg); color: var(--ho-teal); }
.cd-note.bad { background: var(--ho-warn-bg); color: var(--ho-warn); font-weight: 700; }

/* 「只看舞台」：播放器卡片铺满右边（和上面的标题卡片等宽），舞台在中间按 4:3 放大，两边留白 */
.cd-player[data-view="run"] { max-width: none; }
.cd-player[data-view="run"] .cd-player-stage { aspect-ratio: 16 / 9; max-height: 78vh; }
.cd-player[data-view="run"] .cd-player-stage:fullscreen { aspect-ratio: auto; max-height: none; }
@media (max-width: 899px) { .cd-player[data-view="run"] .cd-player-stage { aspect-ratio: 4 / 3; max-height: none; } }

.cd-redeem { margin-top: 10px; font-size: 13px; }
.cd-redeem summary { cursor: pointer; color: var(--hc-brand); font-weight: 700; }
.cd-redeem-row { display: flex; gap: 8px; margin-top: 8px; }
.cd-redeem-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--ho-input-line); border-radius: 10px; background: var(--ho-input-bg); font-size: 14px; text-transform: uppercase; }
.cd-redeem .rdMsg { display: block; margin-top: 6px; }

/* 作品详情页「跟 AI 聊天改程序」：聊天记录 + 气泡——.cd-card 本身不带内边距（靠各处自己的页面用类再加），这张卡之前漏加了，
   和上面「AI 老师教案」卡（.cd-body）内边距对不上，这次两边都用同一组值，留白一致 */
.cd-chat-edit { padding: 20px 22px; }
.cd-chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; padding-right: 2px; }
.cd-chat-log:empty { display: none; }
.cd-chat-msg { max-width: 85%; padding: 8px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.cd-chat-msg.user { align-self: flex-end; background: var(--hc-brand); color: var(--hc-on-brand); border-bottom-right-radius: 4px; }
.cd-chat-msg.ai { align-self: flex-start; background: var(--ho-soft); color: var(--hc-text); border-bottom-left-radius: 4px; }
.cd-chat-msg.ai.wait { color: var(--hc-muted); }
.cd-chat-msg.ai.bad { background: var(--ho-err-bg); color: var(--hc-err); }
.cd-chat-row { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.cd-chat-row textarea { flex: 1; min-width: 0; box-sizing: border-box; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); color: var(--hc-text); border-radius: 14px; padding: 10px 14px; font: inherit; font-size: 14px; resize: vertical; }
.cd-chat-row textarea:focus { outline: 0; border-color: var(--ho-brand-2); box-shadow: var(--ho-ring); }

/* 首页主视觉右边的轮动宣传卡片 */
.ho-carousel { grid-template-columns: minmax(0, 1fr); }
.ho-carousel .ho-slide { grid-area: 1 / 1; position: relative; width: 100%; display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility .5s; }
.ho-carousel .ho-slide.on { opacity: 1; visibility: visible; }
.ho-dots { grid-area: 2 / 1; display: flex; gap: 8px; justify-content: center; padding-top: 14px; }
.ho-dots button { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 999px; background: var(--ho-brand-line); cursor: pointer; transition: width .2s, background .2s; }
.ho-dots button.on { width: 26px; background: var(--ho-brand); }
.cd-mock-ai .cd-mock-code i { white-space: normal; line-height: 1.35; }
.cd-apple { position: absolute; top: 8%; left: 38%; font-size: clamp(22px, 3vw, 34px); animation: cdFall 2.4s ease-in infinite; }
.cd-basket { position: absolute; bottom: 8%; left: 30%; font-size: clamp(30px, 4vw, 46px); animation: cdSlide 2.4s ease-in-out infinite alternate; }
@keyframes cdFall { from { transform: translateY(0); } to { transform: translateY(230%); } }
@keyframes cdSlide { from { transform: translateX(-30%); } to { transform: translateX(60%); } }
.cd-mock-levels { grid-template-columns: 58% 42%; }
.cd-mock-map { background: var(--ho-panel); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.cd-mock-map b { font: 800 12px var(--ho-serif); }
.cd-mock-map .nodes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cd-mock-map .nodes i { font-style: normal; width: 100%; aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 800 11px var(--ho-sans); background: var(--ho-soft-2); border: 2px solid var(--hc-border); }
.cd-mock-map .nodes i.done { background: var(--ho-brand); border-color: var(--ho-brand); color: var(--ho-panel); }
.cd-mock-map .stars { color: var(--ho-star); font-size: 12px; letter-spacing: 2px; }
.cd-mock-hint { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.cd-mock-hint i { font-style: normal; font: 700 11.5px/1.35 var(--ho-sans); padding: 8px 10px; border-radius: 9px; color: var(--ho-panel); box-shadow: 0 2px 0 var(--ho-scrim); }
.cd-mock-hint .ct { background: var(--ho-blk-ctl); } .cd-mock-hint .lk { background: var(--ho-blk-looks); } .cd-mock-hint .mo { background: var(--ho-blk-motion); }
@media (prefers-reduced-motion: reduce) { .cd-apple, .cd-basket { animation: none; } }

.cd-typing { white-space: nowrap; font-weight: 700; }

/* 编程页比通用官网顶栏多一个「哈珀打字」入口，英文导航也更长：给顶栏更多横向空间，
   并确保中间胶囊只在自己的区域内滚动，不能覆盖右侧账号区。中等宽度改成两行。 */
.cd-nav .ho-head-in { max-width: 1480px; }
.cd-nav .ho-brand { flex: 0 1 230px; min-width: 0; overflow: hidden; }
.cd-nav .ho-brand span { min-width: 0; overflow: hidden; }
.cd-nav .ho-brand small { overflow: hidden; text-overflow: ellipsis; }
.cd-menu { min-width: 0; overflow: hidden; }
.cd-menu .group { width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.cd-menu .group::-webkit-scrollbar { display: none; }
.cd-user { position: relative; z-index: 2; background: var(--hc-bg); }

@media (max-width: 1600px) {
  .cd-user .cd-typing .lbl { display: none; }
  .cd-user .cd-typing { padding: 0 10px; }
}

@media (max-width: 1320px) {
  .cd-nav-in { flex-wrap: wrap; }
  .cd-menu { order: 3; flex: 1 0 100%; }
  .cd-user { margin-left: auto; }
}

/* 手机上顶部挤：logo/标题、「哈珀打字」、账号信息本来要分两三行才放得下——窄屏把标题文字收起只留 logo 图标、账号进一步省略、
   间距也收紧，尽量挤回一行，下面标签页单独一行（标签本来就比较多，横向可以滑动，不强求和上面同一行） */
@media (max-width: 480px) {
  .cd-nav-in { gap: 6px; padding: 8px 10px; }
  .ho-tabs { justify-content: stretch; }
  .ho-tabs .group { width: 100%; justify-content: space-between; gap: 0; padding: 3px; overflow: visible; }   /* 6 个标签挤进一行不再横向滑出屏幕（同时「更多」下拉不被裁掉） */
  .ho-tabs a, .ho-tabs button { padding: 8px 6px; font-size: 12.5px; gap: 3px; }
  .cd-nav-in .ho-icon-btn { width: 32px; height: 32px; }
  .cd-nav-in .ho-brand { gap: 6px; }
  .cd-nav-in .ho-brand img { width: 30px; height: 30px; }
  .cd-nav-in .ho-brand b { display: none; }                 /* 登录后这里空间最紧张；logo 图标已经能认出是哪个 App，标题文字先让位 */
  .cd-nav-in .ho-actions { gap: 6px; }
  .cd-user .cd-typing .lbl { display: none; }
  .cd-user .cd-typing { padding: 0 8px; }
  .cd-user .ho-chipuser { padding: 0 6px 0 8px; gap: 4px; }
  .cd-user .ho-chipuser .nm { max-width: 34px; }
  .cd-user .ho-chipuser .q { padding: 1px 5px; }
  .cd-user .ho-chipuser button { padding: 0 4px; }
}

.cd-explain { margin: 12px 0 0; padding: 12px 14px; border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius); background: var(--ho-input-bg); font-size: 13px; }
.cd-explain h5 { margin: 10px 0 4px; font: 800 13px var(--ho-serif); color: var(--hc-brand); }
.cd-code-lines { list-style: none; margin: 0 0 8px; padding: 6px 8px; border-left: 3px solid var(--ho-brand-line); background: var(--ho-panel); border-radius: 0 8px 8px 0; display: flex; flex-direction: column; gap: 5px; }
.cd-code-lines li { line-height: 1.55; }
.cd-code-lines code { font: 700 13px Consolas, Menlo, "Courier New", monospace; color: var(--hc-text); }
.cd-code-lines small { display: block; color: var(--hc-muted); font-size: 12px; line-height: 1.5; }

/* 标签（完整界面 / 只看舞台 / JSON / JavaScript / Python）窄屏时换行，不撑破页面 */
.cd-player { min-width: 0; }
.cd-seg { flex-wrap: wrap; max-width: 100%; }

/* ── 《Python语言编程》（pylang.js）：大纲 / 一课（左任务面板 + 右输出区与编辑器）/ 成绩单 ── */
.py-top { display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.py-top > div:first-child { flex: 1 1 420px; min-width: 0; }
.py-stat { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 800 28px/1 var(--ho-serif); }
.py-stat small { font: 400 13px/1.4 var(--ho-sans, inherit); color: var(--hc-muted); }
.py-mod h2 { font: 800 18px/1.3 var(--ho-serif); margin: 22px 0 10px; }
.py-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.py-cell { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 12px 46px; border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); background: var(--hc-surface); color: var(--hc-text); text-decoration: none; min-height: 74px; }
.py-cell b { position: absolute; left: 12px; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--ho-soft); display: grid; place-items: center; font-size: 12px; }
.py-cell span { font-weight: 700; font-size: 14px; line-height: 1.35; }
.py-cell small { color: var(--hc-muted); font-size: 12px; }
a.py-cell:hover { border-color: var(--hc-brand); }
.py-cell.next { border-color: var(--hc-brand); box-shadow: var(--hc-shadow); }
.py-cell.ok b { background: var(--ho-ok-bg); color: var(--hc-ok); }
.py-cell.skip b { background: var(--ho-warn-bg); color: var(--hc-warn); }
.py-cell.lock, .py-cell.soon { opacity: .55; }
.py-lesson { margin-top: 8px; }
.py-exam { margin-top: 12px; padding: 20px 22px; }
.py-ex { margin: 8px 0 0; }
.py-left, .py-right { padding: 18px; min-width: 0; }
.py-left h1 { font-size: 24px; }
.py-chip { display: inline-block; padding: 3px 12px; border-radius: 999px; background: var(--ho-soft); font-size: 12px; font-weight: 700; color: var(--hc-brand); }
.py-tabs { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--hc-border); border-radius: 999px; background: var(--ho-soft); margin: 6px 0 10px; }
.py-tabs button { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--hc-muted); }
.py-tabs button.on { background: var(--hc-surface); color: var(--hc-brand); box-shadow: var(--hc-shadow); }
.py-pane h3 { font-size: 14px; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.py-pane p, .py-pane li { font-size: 14px; line-height: 1.7; margin: 0 0 4px; }
.py-pane ul, .py-pane ol { margin: 0; padding-left: 20px; }
.py-ex, .py-sample pre { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--ho-soft); font: 13px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.py-prompt { font-weight: 600; line-height: 1.8; margin: 0 0 6px; }
.py-sample { display: grid; grid-template-columns: 64px 1fr 1fr; gap: 12px; align-items: start; margin: 14px 0; }
.py-sample small { color: var(--hc-muted); }
.py-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 22px 0 16px; }
.py-grow { flex: 1; }
.py-work { display: grid; grid-template-columns: minmax(220px, 4fr) minmax(0, 6fr); gap: 20px; align-items: start; margin-top: 4px; }
.py-label { font-size: 13px; font-weight: 700; color: var(--hc-muted); margin: 0 0 8px; }
.py-out { margin: 0 0 18px; min-height: 220px; max-height: 420px; overflow: auto; padding: 12px; border: 1px solid var(--hc-border); border-radius: 16px; background: var(--hc-surface); font: 13px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.py-out.err { color: var(--hc-danger); }
.py-stdin { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--hc-border); border-radius: 12px; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; background: var(--hc-surface); color: var(--hc-text); }
.py-edit { min-width: 0; }
.py-edit > textarea { width: 100%; min-height: 320px; box-sizing: border-box; font: 13px/1.6 ui-monospace, Consolas, monospace; }
.py-result { margin-top: 20px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--hc-border); }
.py-result h3 { margin: 0 0 6px; } .py-result p { margin: 4px 0; font-size: 14px; line-height: 1.7; }
.py-result.good { background: var(--ho-ok-bg); border-color: var(--hc-ok); } .py-result.bad { background: var(--ho-warn-bg); border-color: var(--hc-warn); }
.py-pager { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.py-lesson .cd-pager { margin-top: 28px; padding-bottom: 24px; }
.py-lesson #pyNav { display: inline-flex; gap: 10px; flex-wrap: wrap; }
.py-locked { padding: 24px; margin-top: 12px; }
.py-sheet { padding: 26px; margin-top: 8px; }
.py-sheet h2 { font: 800 18px/1.3 var(--ho-serif); margin: 22px 0 8px; }
.py-tab { width: 100%; border-collapse: collapse; font-size: 14px; }
.py-tab th, .py-tab td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--hc-border); }
@media (max-width: 900px) { .py-work { grid-template-columns: minmax(0, 1fr); } .py-sample { grid-template-columns: 1fr; } }
@media print { .cd-nav, .py-noprint, .ho-head { display: none !important; } .py-sheet { box-shadow: none; border: 0; } }

/* 嵌入模式（官网课程页 iframe，?embed=1）：去掉自己的顶部导航和页脚，内容紧贴顶部；返回「系统课程」列表的链接在嵌入里没意义 */
.cd-embed .cd-nav, .cd-embed .ho-head, .cd-embed .cd-foot, .cd-embed #foot { display: none !important; }
.cd-embed a.cd-sub[href^="#/courses"] { display: none; }
.cd-embed body { padding-top: 0; }
