/* 梯形图助手：样式。版式和哈珀编程一致（哈珀官方界面标准：白色 + 靛紫 + 衬线大标题 + 胶囊导航 + 大圆角卡片）。
   通用组件在 /static/harper-official.css（ho-*），颜色一律引用令牌，不写死。手机优先；≥ 900 左右分栏（对话 | 结果）。 */
body { background: var(--hc-bg); color: var(--hc-text); margin: 0; min-height: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ld-main { max-width: 1320px; margin: 0 auto; padding: 18px 16px calc(84px + env(safe-area-inset-bottom)); }
.ld-h1 { font: 800 28px/1.25 var(--ho-serif); margin: 10px 0 4px; }
.ld-sub { color: var(--hc-muted); margin: 0 0 14px; font-size: 14px; line-height: 1.7; }
.ld-card { background: var(--hc-surface); border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); box-shadow: var(--hc-shadow); }
.ld-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); }
.ld-tag.ok { background: var(--ho-ok-bg); color: var(--hc-ok); } .ld-tag.warn { background: var(--ho-warn-bg); color: var(--hc-warn); } .ld-tag.err { background: var(--ho-err-bg); color: var(--hc-err); }

/* ── 按钮 ── */
.ld-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); }
.ld-btn:hover { background: var(--hc-brand-strong); }
.ld-btn.ghost { background: var(--ho-panel); color: var(--hc-text); border-color: var(--hc-border); box-shadow: none; }
.ld-btn.ghost:hover { border-color: var(--hc-brand); color: var(--hc-brand); }
.ld-btn.sm { min-height: 34px; padding: 4px 14px; font-size: 13px; }
.ld-btn:disabled { opacity: .5; cursor: not-allowed; }
.ld-chip { border: 1px solid var(--hc-border); background: var(--ho-panel); border-radius: 999px; padding: 5px 14px; font-size: 13px; }
.ld-chip:hover { border-color: var(--hc-brand); color: var(--hc-brand); }
.ld-ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── 分栏：手机一次显示一块（底部切换），电脑左右分栏 ── */
.ld-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ld-pane-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94); border-top: 1px solid var(--ho-line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.ld-pane-bar .ld-seg { width: 100%; max-width: 420px; }
.ld-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--hc-border); border-radius: 999px; background: var(--ho-soft); }
.ld-seg button { flex: 1; border: 0; background: transparent; color: var(--hc-muted); padding: 8px 14px; font-size: 14px; font-weight: 700; border-radius: 999px; }
.ld-seg button.on { background: var(--ho-panel); color: var(--hc-text); box-shadow: var(--ho-shadow-seg); }
.ld-split[data-pane="chat"] .ld-result, .ld-split[data-pane="result"] .ld-chat { display: none; }
@media (min-width: 960px) {
  .ld-split { grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); align-items: start; }
  .ld-split[data-pane] .ld-result, .ld-split[data-pane] .ld-chat { display: flex; }
  .ld-pane-bar { display: none; }
  .ld-main { padding-bottom: 40px; }
  .ld-chat { position: sticky; top: 76px; height: calc(100vh - 96px); }
}

/* ── 对话 ── */
.ld-chat { flex-direction: column; display: flex; padding: 0; overflow: hidden; height: calc(100vh - 190px); min-height: 420px; }
.ld-chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--ho-line); }
.ld-chat-head b { font: 800 16px var(--ho-serif); flex: 1; }
.ld-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.ld-msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.ld-msg.u { align-self: flex-end; background: var(--hc-brand); color: var(--hc-on-brand); border-bottom-right-radius: 5px; }
.ld-msg.a { align-self: flex-start; background: var(--ho-soft); border-bottom-left-radius: 5px; }
.ld-msg.e { align-self: flex-start; background: var(--ho-err-bg); color: var(--hc-err); border: 1px solid var(--ho-err-line); }
.ld-msg ul { margin: 6px 0 0; padding-left: 18px; }
.ld-msg .ld-go { margin-top: 8px; display: none; }
.ld-typing { align-self: flex-start; color: var(--hc-muted); font-size: 13px; padding: 4px 8px; }
.ld-hello { text-align: center; padding: 20px 8px; color: var(--hc-muted); font-size: 14px; line-height: 1.8; }
.ld-hello h2 { font: 800 20px var(--ho-serif); color: var(--hc-text); margin: 4px 0; }
.ld-hello .ld-chips { justify-content: center; margin-top: 12px; }
.ld-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.ld-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ho-line); background: var(--hc-surface); }
.ld-compose textarea { flex: 1; resize: none; max-height: 120px; min-height: 42px; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); border-radius: 16px; padding: 10px 14px; line-height: 1.5; }
.ld-compose textarea:focus { outline: 2px solid var(--hc-brand); outline-offset: 0; }
.ld-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 14px 8px; }

/* ── 结果 ── */
.ld-result { flex-direction: column; display: flex; gap: 14px; min-width: 0; }
.ld-empty { padding: 48px 16px; text-align: center; color: var(--hc-muted); line-height: 1.8; }
.ld-empty h2 { font: 800 22px var(--ho-serif); color: var(--hc-text); margin: 8px 0; }
.ld-rhead { padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.ld-rhead h2 { font: 800 22px var(--ho-serif); margin: 0; flex: 1 1 160px; }
.ld-rhead select { border: 1px solid var(--hc-border); border-radius: 999px; padding: 6px 12px; background: var(--ho-panel); font-size: 13px; }
.ld-tools { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.ld-notes { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.7; }
.ld-notes p { margin: 0; padding: 6px 12px; border-radius: 12px; }
.ld-notes .err { background: var(--ho-err-bg); color: var(--hc-err); border: 1px solid var(--ho-err-line); }
.ld-notes .warn { background: var(--ho-warn-bg); color: var(--hc-warn); border: 1px solid var(--ho-warn-line); }
.ld-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--hc-border); padding: 0 8px; }
.ld-tabs button { border: 0; background: transparent; padding: 12px 14px; font-weight: 700; color: var(--hc-muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.ld-tabs button.on { color: var(--hc-brand); border-bottom-color: var(--hc-brand); }
.ld-body { padding: 16px 18px 20px; min-width: 0; }
.ld-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ld-table th, .ld-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--ho-line); }
.ld-table th { color: var(--hc-muted); font-weight: 700; font-size: 12.5px; }
.ld-table td:first-child { font-family: Consolas, "Courier New", monospace; font-weight: 700; color: var(--hc-brand); white-space: nowrap; }
.ld-code { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--ho-dark); color: var(--ho-on-dark); font: 13px/1.65 Consolas, "Courier New", monospace; overflow: auto; max-height: 560px; white-space: pre; tab-size: 4; }
.ld-sketch { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; background: var(--ho-soft); font: 12.5px/1.6 Consolas, "Courier New", monospace; overflow-x: auto; white-space: pre; }
.ld-sec-h { font: 800 16px var(--ho-serif); margin: 18px 0 8px; }
.ld-sec-h:first-child { margin-top: 0; }

/* 状态流程 */
.ld-flow { display: grid; gap: 10px; }
.ld-state { border: 1px solid var(--ho-card-line); border-radius: 16px; padding: 12px 14px; background: var(--ho-panel); }
.ld-state.init { border-color: var(--hc-brand); box-shadow: 0 0 0 3px var(--hc-brand-soft); }
.ld-state-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ld-state-h b { font-size: 15px; }
.ld-state-h code { font: 700 12px Consolas, monospace; color: var(--hc-brand); background: var(--hc-brand-soft); padding: 2px 8px; border-radius: 999px; }
.ld-state ul { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: 13.5px; line-height: 1.8; color: var(--hc-muted); }
.ld-state li b { color: var(--hc-text); }

/* 梯形图 */
.ld-net { border: 1px solid var(--ho-card-line); border-radius: 16px; margin-bottom: 12px; overflow: hidden; background: var(--ho-panel); }
.ld-net > header { padding: 9px 14px; background: var(--ho-soft); font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.ld-net > header small { color: var(--hc-muted); font-weight: 400; }
.ld-net-in { padding: 12px 14px; overflow-x: auto; }
.ld-svg { display: block; }
.ld-svg .w { stroke: var(--hc-text); stroke-width: 2; fill: none; }
.ld-svg .bus { stroke: var(--hc-brand); stroke-width: 3; }
.ld-svg .c { stroke: var(--hc-brand); stroke-width: 2.5; fill: none; }
.ld-svg .box { stroke: var(--hc-brand); stroke-width: 2; fill: var(--hc-brand-soft); }
.ld-svg text { fill: var(--hc-text); font: 700 12px Consolas, "Courier New", monospace; text-anchor: middle; }
.ld-svg text.s { fill: var(--hc-muted); font-weight: 400; font-size: 11px; }
.ld-svg text.k { fill: var(--hc-brand); font-size: 14px; }
.ld-steps { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.9; }
.ld-steps li::marker { color: var(--hc-brand); font-weight: 700; }
.ld-json { width: 100%; min-height: 320px; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); border-radius: 14px; padding: 12px; font: 13px/1.6 Consolas, "Courier New", monospace; resize: vertical; }

/* 向导 / 设置 */
.ld-page { max-width: 860px; margin: 0 auto; }
.ld-guide-step { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--ho-line); }
.ld-guide-step:last-child { border: 0; }
.ld-guide-step input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--hc-brand); flex: none; }
.ld-guide-step b { display: block; font-size: 15px; }
.ld-guide-step span { display: block; color: var(--hc-muted); font-size: 13.5px; line-height: 1.7; margin-top: 2px; }
.ld-guide-step.done b { text-decoration: line-through; color: var(--hc-muted); }
.ld-form { padding: 18px; display: grid; gap: 12px; }
.ld-form label { font-weight: 700; font-size: 14px; display: grid; gap: 6px; }
.ld-form label small { color: var(--hc-muted); font-weight: 400; line-height: 1.6; }
.ld-form textarea { min-height: 200px; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); border-radius: 14px; padding: 12px; font: 13px/1.6 Consolas, monospace; }

.ld-foot { text-align: center; padding: 22px 16px; color: var(--hc-faint); font-size: 12.5px; line-height: 1.8; }
.ld-toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; max-width: 90vw; padding: 10px 18px; border-radius: 999px; background: var(--ho-dark); color: var(--ho-on-dark); font-size: 14px; box-shadow: var(--ho-shadow-pop); }
@media (min-width: 960px) { .ld-toast { bottom: 30px; } }
@media (max-width: 860px) { .ho-brand small { display: none; } .ld-h1 { font-size: 24px; } }
.ld-compose textarea { scrollbar-width: none; }
.ld-compose textarea::-webkit-scrollbar { display: none; }

/* AI 老师教案 + 追加聊天 */
.ld-lesson { padding: 6px 4px; font-size: 15px; line-height: 1.95; }
.ld-lesson p { margin: 0 0 12px; }
.ld-lesson b { color: var(--hc-brand); font-family: var(--ho-serif); }
.ld-follow { display: flex; gap: 8px; align-items: flex-end; }
.ld-follow textarea { flex: 1; min-height: 56px; resize: vertical; border: 1px solid var(--ho-input-line); background: var(--ho-input-bg); border-radius: 16px; padding: 10px 14px; line-height: 1.5; }
.ld-follow textarea:focus { outline: 2px solid var(--hc-brand); outline-offset: 0; }

.ld-editable{cursor:pointer}.ld-editable:hover{fill:var(--ho-brand,#4f46e5);text-decoration:underline}
.ld-prop-mask{position:fixed;inset:0;z-index:1000;background:rgba(31,36,51,.32);display:none;place-items:center;padding:18px}.ld-prop-mask.on{display:grid}
.ld-prop{position:relative;width:min(390px,100%);background:#fff;border:1px solid var(--ho-line,#e5e7ef);border-radius:20px;padding:24px;box-shadow:0 22px 60px rgba(31,36,51,.2)}
.ld-prop h3{margin:0 0 14px;font:800 22px Georgia,"Songti SC",serif}.ld-prop label{display:block;margin:10px 0;font-size:13px;color:#4b5563}.ld-prop input,.ld-prop select{display:block;width:100%;margin-top:5px;padding:9px 12px;border:1px solid #d9dce8;border-radius:10px;background:#fff;font:inherit}
.ld-prop-x{position:absolute;right:12px;top:10px;border:0;background:none;font-size:24px;color:#6b7280;cursor:pointer}.ld-prop-msg{min-height:20px;color:#b91c1c;font-size:12.5px}.ld-prop-actions{display:flex;gap:8px;margin-top:12px}

/* ── 数字孪生教学面板（3D 仿真 + 学习面板）── */
.tw { display: flex; flex-direction: column; gap: 12px; }
.tw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tw-grow { flex: 1; }
.tw-speed { font-size: 13px; color: var(--hc-muted); display: inline-flex; align-items: center; gap: 4px; }
.tw-speed select { border: 1px solid var(--hc-border); border-radius: 999px; padding: 4px 8px; background: var(--ho-panel); }
.tw-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 1180px) { .tw-grid { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); align-items: start; } .tw-stage { position: sticky; top: 76px; } }
.tw-stage { position: relative; border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); overflow: hidden; background: var(--ho-soft); height: clamp(320px, 56vh, 560px); touch-action: none; }
.tw-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.tw-tip { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: var(--hc-muted); background: rgba(255, 255, 255, .85); padding: 3px 10px; border-radius: 999px; pointer-events: none; }
.tw-note { position: absolute; left: 10px; top: 8px; right: 10px; font-size: 13px; color: var(--hc-brand); font-weight: 700; pointer-events: none; z-index: 2; }
.tw-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tw-card { border: 1px solid var(--ho-card-line); border-radius: var(--hc-radius-lg); padding: 12px 14px; background: var(--hc-surface); }
.tw-card h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: baseline; gap: 8px; }
.tw-card h4 small { color: var(--hc-muted); font-weight: 500; font-size: 12px; }
.tw-flow { display: flex; flex-wrap: wrap; gap: 4px 2px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.tw-flow i { color: var(--hc-muted); font-style: normal; }
.tw-fs { padding: 2px 9px; border-radius: 999px; border: 1px solid var(--hc-border); color: var(--hc-muted); }
.tw-fs.on { background: var(--hc-brand); border-color: var(--hc-brand); color: var(--hc-on-brand); font-weight: 700; }
.tw-now b { font-size: 15px; } .tw-now code { margin-left: 8px; font-size: 12px; color: var(--hc-muted); }
.tw-now ul, .tw-tips, .tw-log { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; line-height: 1.7; }
.tw-now li.do::before { content: "●"; color: var(--hc-ok); margin-right: 6px; }
.tw-now li.mu, .tw-empty { color: var(--hc-muted); font-size: 13px; }
.tw-now li.wait span.n { color: var(--hc-warn); } .tw-now li.wait span.y, .tw-now li.ok span.y { color: var(--hc-ok); }
.tw-now li.ok { font-weight: 700; }
.tw-h { margin: 8px 0 0; font-size: 12px; color: var(--hc-muted); }
.tw-timer, .tw-var { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 12px; margin: 6px 0; }
.bar { height: 8px; border-radius: 999px; background: var(--ho-soft); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--hc-brand); border-radius: 999px; transition: width .12s linear; }
.tw-var .bar i { background: #3b9cff; }
.tw-io { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.tw-io-i { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; text-align: left; padding: 7px 10px; border: 1px solid var(--hc-border); border-radius: 12px; background: var(--ho-panel); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button.tw-io-i:hover { border-color: var(--hc-brand); }
.tw-io-i span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; } .tw-io-i small { color: var(--hc-muted); font-size: 11px; }
.tw-io-i em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--hc-muted); }
.tw-io-i .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--hc-border); }
.tw-io-i.on { border-color: var(--hc-ok); background: var(--ho-ok-bg); } .tw-io-i.on .dot { background: var(--hc-ok); box-shadow: 0 0 8px var(--hc-ok); } .tw-io-i.on em { color: var(--hc-ok); }
.tw-io-i.out.on { border-color: var(--hc-warn); background: var(--ho-warn-bg); } .tw-io-i.out.on .dot { background: var(--hc-warn); box-shadow: 0 0 8px var(--hc-warn); } .tw-io-i.out.on em { color: var(--hc-warn); }
.tw-io-i.forced { outline: 2px dashed var(--hc-warn); }
.tw-tips li { padding-left: 12px; position: relative; color: var(--hc-text); } .tw-tips li::before { content: "·"; position: absolute; left: 2px; color: var(--hc-brand); font-weight: 900; }
.tw-log li { display: flex; gap: 8px; font-size: 12px; } .tw-log time { color: var(--hc-muted); font-family: ui-monospace, Consolas, monospace; flex: none; min-width: 44px; }
.tw-log li.st { font-weight: 700; color: var(--hc-brand); } .tw-log li.out { color: var(--hc-warn); } .tw-log li.in { color: var(--hc-ok); }

/* ── 数字孪生：视图切换、接线图、导学 / 导训 ── */
.tw-views, .tw-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--hc-border); border-radius: 999px; background: var(--ho-soft); }
.tw-views button, .tw-seg button { border: 0; background: transparent; color: var(--hc-muted); padding: 6px 14px; font-size: 13px; font-weight: 700; border-radius: 999px; }
.tw-views button.on, .tw-seg button.on { background: var(--ho-panel); color: var(--hc-brand); box-shadow: var(--ho-shadow-seg); }
.tw-seg { display: flex; width: 100%; margin-bottom: 10px; } .tw-seg button { flex: 1; }
.tw-banner { position: absolute; left: 10px; right: 10px; top: 34px; z-index: 3; padding: 6px 12px; border-radius: 12px; background: var(--ho-err-bg); color: var(--hc-err); font-size: 13px; font-weight: 700; }
.tw-wire { position: absolute; inset: 0; overflow: auto; background: var(--hc-surface); padding: 8px 8px 0; }
.tw-svg { width: 100%; height: auto; display: block; max-height: calc(100% - 64px); }
.tw-cap { margin: 6px 6px 10px; font-size: 12px; line-height: 1.7; color: var(--hc-muted); }
/* 接线图配色：导线默认灰，ON 时变色并出现流动的“电流” */
.tw-svg { font-family: "Microsoft YaHei", PingFang SC, sans-serif; }
.tw-svg .rail, .tw-svg .bus { stroke-width: 4; } .tw-svg .rail.p, .tw-svg .bus.p { stroke: #dc2626; } .tw-svg .rail.n, .tw-svg .bus.n { stroke: #2563eb; }
.tw-svg .rl { font: 700 13px sans-serif; } .tw-svg .rl.p { fill: #dc2626; } .tw-svg .rl.n { fill: #2563eb; }
.tw-svg .plc { fill: var(--ho-soft); stroke: var(--hc-brand); stroke-width: 2; } .tw-svg .pl { font: 800 16px sans-serif; fill: var(--hc-brand); } .tw-svg .ps, .tw-svg .tn, .tw-svg .tl, .tw-svg .dl { font: 12px sans-serif; fill: var(--hc-muted); } .tw-svg .dl { fill: var(--hc-text); font-weight: 600; }
.tw-svg .tl { font-family: ui-monospace, Consolas, monospace; fill: var(--hc-text); }
.tw-svg .term { fill: var(--ho-panel); stroke: var(--hc-muted); stroke-width: 2; }
.tw-svg .w { fill: none; stroke: #9aa3c7; stroke-width: 2.4; stroke-linecap: round; } .tw-svg .w.c { stroke: #cbd1ea; stroke-dasharray: 3 4; }
.tw-svg .w.p { stroke: #dc2626; } .tw-svg .w.n { stroke: #2563eb; }
.tw-svg .w.in.on { stroke: #16a34a; stroke-width: 3.2; stroke-dasharray: 8 7; animation: tw-flow .7s linear infinite; }
.tw-svg .w.out.on { stroke: #f59e0b; stroke-width: 3.2; stroke-dasharray: 8 7; animation: tw-flow .7s linear infinite; }
.tw-svg .w.ok { stroke: #16a34a; } .tw-svg .w.bad { stroke: #dc2626; stroke-dasharray: 5 5; }
@keyframes tw-flow { to { stroke-dashoffset: -30; } }
.tw-svg .sym * { fill: none; stroke: var(--hc-text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; } .tw-svg .sym .gl { fill: var(--hc-text); stroke: none; font: 800 15px sans-serif; }
.tw-svg .sym .bf { display: none; } .tw-svg .sym.on .bf { display: block; stroke: #16a34a; } .tw-svg .sym.on .bo { display: none; } .tw-svg .sym .dash { stroke-dasharray: 3 3; stroke-width: 1.4; } .tw-svg .sym .dot { fill: var(--hc-text); }
.tw-svg .sym.load.on * { stroke: #f59e0b; } .tw-svg .sym.load.on circle, .tw-svg .sym.load.on rect { fill: #fde68a; } .tw-svg .sym.load.on .gl { fill: #b45309; }
.tw-svg .body { fill: #eef0fb; stroke: #4f46e5; stroke-width: 2.5; } .tw-svg .strip { fill: #2b3350; } .tw-svg .brand { font: 800 20px sans-serif; fill: var(--hc-brand); } .tw-svg .brand2 { font: 600 13px sans-serif; fill: var(--hc-muted); }
.tw-svg .strip + .strip { fill: #2b3350; } .tw-svg .led { fill: #cfd3ea; stroke: #9aa3c7; } .tw-svg .led.on { fill: #22c55e; stroke: #16a34a; filter: drop-shadow(0 0 4px #22c55e); } .tw-svg .led-run { fill: #cfd3ea; } .tw-svg .led-run.on { fill: #22c55e; }
.tw-svg .strip ~ circle.term { fill: #d9dcea; stroke: #6b7280; }
.tw-svg .dev .b { fill: #d7dcf0; stroke: #6b7399; stroke-width: 2; } .tw-svg .dev .b2 { fill: #aab3d6; stroke: #6b7399; stroke-width: 2; } .tw-svg .dev .p { fill: #94a3b8; } .tw-svg .dev .fin, .tw-svg .dev .lever { fill: none; stroke: #6b7399; stroke-width: 2.4; stroke-linecap: round; }
.tw-svg .dev .led { fill: #94a3b8; stroke: #6b7399; } .tw-svg .dev .gl { fill: #6b7399; font: 800 14px sans-serif; }
.tw-svg .dev.on .led { fill: #22c55e; filter: drop-shadow(0 0 6px #22c55e); } .tw-svg .dev.on .b { fill: #fde68a; stroke: #f59e0b; filter: drop-shadow(0 0 6px #f59e0b); } .tw-svg .dev.on .b2 { fill: #fcd34d; }
/* 导学 */
.tw-learn { padding-top: 10px; }
.tw-gh { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--hc-muted); font-weight: 700; }
.tw-dots { display: flex; gap: 5px; margin: 8px 0; } .tw-dots i { flex: 1; height: 5px; border-radius: 999px; background: var(--hc-border); } .tw-dots i.d { background: var(--hc-ok); } .tw-dots i.c { background: var(--hc-brand); }
.tw-learn h5 { margin: 4px 0 6px; font-size: 15px; } .tw-learn p { margin: 6px 0; font-size: 13px; line-height: 1.75; }
.tw-learn .say { color: var(--hc-text); } .tw-learn .look { padding: 8px 10px; border-radius: 12px; background: var(--ho-ok-bg); color: var(--hc-ok); } .tw-todo { color: var(--hc-muted); }
.tw-pause { color: var(--hc-warn); font-weight: 700; } .tw-win { padding: 8px 10px; border-radius: 12px; background: var(--hc-brand-soft); color: var(--hc-brand); font-weight: 700; }
.tw-lad { margin: 8px 0; font-size: 12px; } .tw-lad summary { cursor: pointer; color: var(--hc-brand); font-weight: 700; } .tw-lad pre { margin: 6px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--ho-soft); font: 12px/1.6 ui-monospace, Consolas, monospace; overflow-x: auto; }
.tw-gb { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; } .tw-opt-l { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--hc-muted); margin-top: 8px; }
.tw-io-i.hl { outline: 2px solid #ff7a45; animation: tw-pulse 1s ease-in-out infinite; } @keyframes tw-pulse { 50% { outline-offset: 3px; box-shadow: 0 0 10px #ff7a45; } }
/* 导训 */
.tw-score { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; } .tw-score b { font-size: 22px; color: var(--hc-brand); }
.tw-task { border-top: 1px solid var(--ho-line); padding: 10px 0; } .tw-task h5 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 14px; } .tw-task h5 em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--hc-muted); } .tw-task h5 em.ok { color: var(--hc-ok); font-weight: 700; }
.tw-task .no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--hc-brand-soft); color: var(--hc-brand); font-size: 12px; }
.tw-task p { margin: 4px 0; font-size: 13px; line-height: 1.7; } .tw-task .q { font-weight: 700; }
.tw-opts { display: grid; gap: 6px; } .tw-opt { text-align: left; padding: 8px 12px; border: 1px solid var(--hc-border); border-radius: 12px; background: var(--ho-panel); font-size: 13px; line-height: 1.5; }
.tw-opt:hover:not(:disabled) { border-color: var(--hc-brand); } .tw-opt.right { border-color: var(--hc-ok); background: var(--ho-ok-bg); color: var(--hc-ok); font-weight: 700; } .tw-opt.wrong { border-color: var(--hc-err); background: var(--ho-err-bg); color: var(--hc-err); }
.tw-fb { padding: 8px 10px; border-radius: 12px; font-size: 13px; } .tw-fb.ok { background: var(--ho-ok-bg); color: var(--hc-ok); } .tw-fb.bad { background: var(--ho-warn-bg); color: var(--hc-warn); }
.tw-wrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 10px; font-size: 13px; } .tw-wrow small { display: block; color: var(--hc-muted); font-size: 11px; } .tw-wrow select { border: 1px solid var(--hc-border); border-radius: 999px; padding: 4px 8px; background: var(--ho-panel); }
.tw-wrow.ok { background: var(--ho-ok-bg); } .tw-wrow.bad { background: var(--ho-err-bg); } .tw-wrow em { font-style: normal; font-size: 12px; font-weight: 700; min-width: 56px; }

/* ── 全屏训练 ── */
html.tw-noscroll, html.tw-noscroll body { overflow: hidden; }
.tw.tw-full { position: fixed; inset: 0; z-index: 2000; box-sizing: border-box; height: 100vh; height: 100dvh; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--hc-bg); overflow-y: auto; }
.tw.tw-full .tw-stage { height: 56vh; position: relative; top: 0; }
@media (min-width: 900px) {
  .tw.tw-full { overflow: hidden; }
  .tw.tw-full .tw-grid { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); flex: 1; min-height: 0; align-items: stretch; }
  .tw.tw-full .tw-stage { height: 100%; min-height: 0; }
  .tw.tw-full .tw-side { overflow-y: auto; min-height: 0; padding-right: 4px; }
}

/* ── 梯形图监控浮动窗（可拖动 / 可缩放）── */
.tw { position: relative; }
.tw-ladwin { position: absolute; z-index: 30; display: flex; flex-direction: column; min-width: 280px; min-height: 200px; max-width: calc(100vw - 16px); background: var(--hc-surface); border: 1px solid var(--hc-brand); border-radius: 16px; box-shadow: 0 18px 48px rgba(31, 36, 51, .28); resize: both; overflow: hidden; }
.tw-ladhead { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--hc-brand); color: var(--hc-on-brand); cursor: grab; user-select: none; touch-action: none; font-size: 13px; }
.tw-ladhead:active { cursor: grabbing; } .tw-ladhead span { font-size: 12px; opacity: .85; flex: 1; } .tw-ladhead label { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; }
.tw-ladhead button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .22); color: inherit; font-size: 18px; line-height: 1; }
.tw-ladbody { flex: 1; overflow: auto; padding: 8px; position: relative; }
.tl-net { border: 1px solid var(--ho-line); border-radius: 12px; margin-bottom: 8px; background: var(--hc-surface); } .tl-net header { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--ho-line); } .tl-net header small { color: var(--hc-muted); font-weight: 500; flex: 1; } .tl-net header em { display: none; font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--hc-brand); color: var(--hc-on-brand); }
.tl-net.live { border-color: var(--hc-brand); box-shadow: 0 0 0 2px var(--hc-brand-soft); } .tl-net.live header em { display: inline-block; }
.tl-in { overflow-x: auto; }
.tl-svg { display: block; font-family: ui-monospace, Consolas, "Microsoft YaHei", sans-serif; }
.tl-svg .w, .tl-svg .ct line, .tl-svg .cl path, .tl-svg .bus { stroke: #9aa3c7; stroke-width: 2; fill: none; stroke-linecap: round; } .tl-svg .bus { stroke: var(--hc-text); stroke-width: 3; }
.tl-svg .ad { font-size: 11px; fill: var(--hc-text); font-weight: 700; } .tl-svg .nt { font-size: 10px; fill: var(--hc-muted); font-family: "Microsoft YaHei", sans-serif; } .tl-svg .kw { font-size: 12px; font-weight: 800; fill: var(--hc-brand); } .tl-svg .st { font-size: 11px; fill: var(--hc-muted); }
.tl-svg .bx { fill: none; stroke: #9aa3c7; stroke-width: 2; }
.tl-svg .w.on { stroke: #16a34a; stroke-width: 3; } .tl-svg .ct.on line { stroke: #16a34a; stroke-width: 3; } .tl-svg .cl.on path { stroke: #f59e0b; stroke-width: 3; filter: drop-shadow(0 0 4px #f59e0b); } .tl-svg .bx.on { stroke: #f59e0b; fill: #fef3c7; } .tl-svg text.on { fill: #b45309; }

.ld-hit{fill:var(--ho-brand,#4f46e5);fill-opacity:0;cursor:pointer}.ld-hit:hover{fill-opacity:.1}
.ld-net-tools{margin-left:auto;display:flex;gap:6px}.ld-net > header .ld-net-tools .ld-btn{min-height:28px;padding:2px 10px;font-size:12px}
.ld-lad-bar{display:flex;gap:12px;align-items:center;justify-content:space-between;margin-bottom:8px}
.ld-lad-bar .ld-sub{margin:0}
.ld-lad-card{position:relative}
.lad{overflow:auto;max-height:62vh;border:1px solid var(--ho-card-line,#eef0f6);border-radius:12px;background:#fff;padding:6px}
.ld-err{min-height:18px;font-size:12.5px;color:var(--hc-muted,#6b7280);margin-top:6px}
/* 梯形图编辑器工具条：改用哈珀官方令牌，和助手其他按钮一致 */
.ld-lad-card .le-tools{background:var(--ho-soft,#f0f1f8);border:1px solid var(--ho-line,#e8eaf3);border-radius:14px;padding:8px;gap:6px}
.ld-lad-card .le-tools button{min-height:30px;padding:3px 12px;border-radius:999px;border:1px solid var(--ho-line,#e8eaf3);background:var(--ho-panel,#fff);color:var(--ho-ink,#0b1220);font-size:12.5px;font-weight:700;box-shadow:none;cursor:pointer}
.ld-lad-card .le-tools button:hover{border-color:var(--ho-brand,#4f46e5);color:var(--ho-brand,#4f46e5)}
.ld-lad-card .le-tools button.on{background:var(--ho-brand,#4f46e5);border-color:var(--ho-brand,#4f46e5);color:#fff}
.ld-lad-card .le-tools .le-sep{background:var(--ho-line,#e8eaf3)}
.ld-lad-card .le-tools .le-label{color:var(--ho-muted,#7a7f98);font-weight:700}
.ld-lad-card .le-selection{background:var(--ho-brand-soft,#eeecff);border-top:1px solid var(--ho-brand-line,#d9d4fb);border-radius:12px}
.ld-lad-card .le-selection b{color:var(--ho-brand-strong,#4338ca)}
.ld-lad-card .le-warns button{background:#fffbeb;color:#92400e;border-radius:8px;font-size:12px;padding:4px 8px;text-align:left}
.ld-lad-card .le-pop{border:1px solid var(--ho-brand-line,#d9d4fb);border-radius:16px;box-shadow:var(--ho-shadow-pop,0 18px 48px rgba(31,36,51,.18))}
.ld-lad-card .le-pop h4{color:var(--ho-brand-strong,#4338ca)}
.ld-lad-card .le-pop button{border-radius:999px;border:1px solid var(--ho-line,#e8eaf3);background:#fff;font-weight:700;padding:5px 12px;cursor:pointer}
.ld-lad-card .le-pop button.primary{background:var(--ho-brand,#4f46e5);border-color:var(--ho-brand,#4f46e5);color:#fff}
.ld-lad-card .le-pop input,.ld-lad-card .le-pop select{border-color:var(--ho-line,#e8eaf3);border-radius:10px}
.ld-awl-bar{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}
.ld-awl-edit{min-height:420px;white-space:pre;overflow:auto}
.ld-awl-full{margin-top:14px}
.ld-awl-full summary{cursor:pointer;font-size:13px;font-weight:700;color:var(--hc-muted);margin-bottom:8px}
