/* ==========================================================================
   3MFit · PRINT-BED BLUEPRINT（热床蓝图）
   设计语言：深空蓝黑基底 + 蓝图青 accent + 工程网格 + G 码刀路母题 +
   XYZ 原点轴标（RGB 仅用于轴语义）。零外部资源：图形全部 inline SVG /
   CSS 渐变；字体用系统栈（数据用 ui-monospace）。
   动效约定：仅 transform/opacity/stroke-dashoffset，全部 respect
   prefers-reduced-motion（降级为终态静态呈现）。
   ========================================================================== */

:root {
  /* 基底 · 深空蓝黑 */
  --bg: #070d16;
  --bg-raised: #0b1420;
  --bg-hover: #0f1b2c;
  --line: #182a40;
  --line-strong: #24405e;

  /* 工程网格（两层密度，克制透明度） */
  --grid-minor: rgba(110, 175, 235, .045);
  --grid-major: rgba(110, 175, 235, .09);

  /* 文本 */
  --ink: #e9f1f9;
  --ink-dim: #93a6bd;      /* 在 --bg 上 ≈7.5:1，满足正文 ≥4.5:1 */
  --ink-faint: #5b738e;    /* 仅装饰性标注（aria-hidden 内容） */

  /* 蓝图青 accent 系 */
  --accent: #4fc8f5;
  --accent-ink: #052536;   /* accent 底上的深色文字（≈10:1） */
  --accent-dim: #2b6a8c;
  --accent-glow: rgba(79, 200, 245, .22);

  /* 语义色 */
  --ok: #41d897;
  --warn: #f2bd4a;
  --err: #fb6f7b;
  --amber: #fba04c;        /* CS-11 warn 级警告：在 --bg 上 ≈9.5:1；与 --warn 黄、--err 红分层 */

  /* XYZ 轴标三原色（仅轴语义，不作他用） */
  --axis-x: #ff5d4d;
  --axis-y: #43d675;
  --axis-z: #4a9eff;

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::selection { background: rgba(79, 200, 245, .28); color: var(--ink); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
}

/* 整页工程网格：细网格 + 主网格，径向渐隐，顶部一抹蓝图青光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px, 130px 130px, 130px 130px;
  mask-image: radial-gradient(ellipse 100% 85% at 50% 0%, #000 25%, rgba(0,0,0,.4) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 55% 32% at 50% -6%, var(--accent-glow), transparent 70%);
  opacity: .55;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 20px 72px;
}

/* 仅对屏幕阅读器可见，同时保持元素可聚焦（不能 display:none） */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono { font-family: var(--mono); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  text-align: center;
  margin-bottom: 30px;
  padding: 8px 0 4px;
}

/* G 码刀路母题：回纹刀路，载入时自绘制一次，随后静卧 */
.hero-toolpath {
  position: absolute;
  top: -38px;
  right: -10px;
  width: 190px;
  height: 190px;
  opacity: .14;
  pointer-events: none;
  mask-image: radial-gradient(circle at 60% 40%, #000 30%, transparent 75%);
}
.hero-toolpath path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: toolpath-draw 1.8s .25s cubic-bezier(.4, 0, .2, 1) forwards;
}
@keyframes toolpath-draw { to { stroke-dashoffset: 0; } }

.hero-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 4px 18px rgba(79, 200, 245, .25));
}
.hero h1 {
  font-size: 40px;
  letter-spacing: -.5px;
  line-height: 1.1;
}
.hero h1 .fit { color: var(--accent); }
.tagline { color: var(--ink-dim); margin-top: 10px; font-size: 15px; }
.hero-meta {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .22em;
  color: var(--ink-faint);
}

/* ---------- 分区标题（蓝图编号标注） ---------- */

h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
.sec-index {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .05em;
}
.sec-index::after { content: " /"; color: var(--ink-faint); }
#resultTitle:focus { outline: none; }

/* ---------- 状态行 ---------- */

#statusBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 18px;
  min-height: 20px;
}
#statusBar::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: status-pulse 1.6s ease-in-out infinite;
}
@keyframes status-pulse { 50% { opacity: .35; box-shadow: none; } }

/* ---------- 卡片（蓝图角标 + 细描边） ---------- */

.card {
  position: relative;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1v10M1 6h10' stroke='%2328405c' stroke-width='1.2'/%3E%3C/svg%3E") 10px 10px / 12px 12px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1v10M1 6h10' stroke='%2328405c' stroke-width='1.2'/%3E%3C/svg%3E") right 10px bottom 10px / 12px 12px no-repeat,
    linear-gradient(180deg, rgba(255,255,255,.018), transparent 30%),
    var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}

/* ---------- 拖放区 = 热床（role="button"，键盘可达） ---------- */

#dropzone {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 52px 20px 48px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
  margin-bottom: 16px;
  /* 床面网格：比整页更密，随拖拽态提亮 */
  background-image:
    linear-gradient(rgba(110,175,235,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,175,235,.06) 1px, transparent 1px),
    linear-gradient(rgba(110,175,235,.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,175,235,.11) 1px, transparent 1px),
    linear-gradient(180deg, #0a141f, #081019);
  background-size: 14px 14px, 14px 14px, 70px 70px, 70px 70px, 100% 100%;
}
#dropzone:hover, #dropzone.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 12px 44px -16px var(--accent-glow);
}
#dropzone.disabled { opacity: .55; cursor: wait; }
#dropzone .drop-text { display: block; font-size: 15px; }
#dropzone .hint { display: block; color: var(--ink-dim); font-size: 13px; margin-top: 8px; }

/* 喷嘴图标（替代 emoji，线稿风） */
.nozzle-icon {
  display: block;
  width: 46px; height: 46px;
  margin: 0 auto 12px;
}
.nozzle-icon .nozzle-body { stroke: var(--ink); stroke-width: 2.2; }
.nozzle-icon .nozzle-feed { stroke: var(--accent); stroke-width: 2.2; }
.nozzle-icon .nozzle-layers { stroke: var(--accent); stroke-width: 2; opacity: .7; }
#dropzone:hover .nozzle-icon .nozzle-feed,
#dropzone.dragover .nozzle-icon .nozzle-feed { animation: extrude 1s ease-in-out infinite; }
@keyframes extrude { 50% { transform: translateY(2px); } }

/* 拖拽时床框刀路（marching ants） */
.bed-ants {
  position: absolute;
  inset: 7px;
  width: calc(100% - 14px);
  height: calc(100% - 14px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
}
.bed-ants rect {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  animation: ants 1.1s linear infinite;
}
#dropzone.dragover .bed-ants { opacity: 1; }
@keyframes ants { to { stroke-dashoffset: -8; } }

/* XYZ 原点轴标：Bambu 用户一眼会心的暗号，RGB 三原色仅此一处 */
.bed-axes {
  position: absolute;
  left: 14px;
  bottom: 12px;
  width: 40px; height: 40px;
  opacity: .85;
  pointer-events: none;
}
.bed-axes .axis-x { stroke: var(--axis-x); stroke-width: 1.8; }
.bed-axes .axis-y { stroke: var(--axis-y); stroke-width: 1.8; }
.bed-axes .axis-z { stroke: var(--axis-z); stroke-width: 1.8; }
.bed-axes .axis-letters text {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 700;
  stroke: none;
}
.bed-axes .axis-letters .axis-x { fill: var(--axis-x); }
.bed-axes .axis-letters .axis-y { fill: var(--axis-y); }
.bed-axes .axis-letters .axis-z { fill: var(--axis-z); }

/* ---------- 工程信息 ---------- */

.facts .row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 3px 0; }
.facts dt {
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 12px;
  flex: 0 0 58px;
}
.facts dd { min-width: 0; }
.value { font-weight: 600; word-break: break-all; }
.value.mono { font-family: var(--mono); font-size: 13.5px; letter-spacing: .02em; }

/* ---------- 徽标（等宽芯片） ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(65,216,151,.35); background: rgba(65,216,151,.10); }
.badge.warn { color: var(--warn); border-color: rgba(242,189,74,.35); background: rgba(242,189,74,.10); }
.badge.err { color: var(--err); border-color: rgba(251,111,123,.35); background: rgba(251,111,123,.10); }
.badge.info { color: var(--accent); border-color: rgba(79,200,245,.35); background: rgba(79,200,245,.10); }
.badge.amber { color: var(--amber); border-color: rgba(251,160,76,.35); background: rgba(251,160,76,.10); }

.msg { margin-top: 12px; font-size: 14px; }
.msg:empty { display: none; }

/* ---------- 目标机型网格（每台机型一张小图纸） ---------- */

.target-fieldset { border: 0; min-width: 0; }
.targets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.target {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px 13px;
  cursor: pointer;
  background: rgba(255,255,255,.012);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.target:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.target.selected {
  border-color: var(--accent);
  background: rgba(79,200,245,.06);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 32px -16px var(--accent-glow);
}
.target:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 小图纸：按目标床面 X:Y 比例的迷你热床 + T9b 真实摆位预览（--ar 由 JS 按契约数据写入） */
.bed-glyph {
  display: block;
  height: 32px;
  aspect-ratio: var(--ar, 1 / 1);
  margin-bottom: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background-image:
    linear-gradient(rgba(110,175,235,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,175,235,.14) 1px, transparent 1px);
  background-size: 8px 8px;
  position: relative;
}
/* 摆位预览覆盖层：SVG 视图坐标 = 床面 mm（Y 轴翻转，0,0=前左角）；描边恒定 1px 视觉宽 */
.bed-glyph .glyph-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.glyph-model {
  fill: rgba(79,200,245,.16);
  stroke: var(--accent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.glyph-model.out {
  fill: rgba(251,111,123,.18);
  stroke: var(--err);
}
.glyph-exclusion { fill: rgba(251,160,76,.30); }
.target.selected .bed-glyph { border-color: var(--accent); }

.target .name { font-weight: 600; display: block; font-size: 14.5px; }
.target .badges { display: block; margin-top: 5px; min-height: 20px; }
.target .badges .badge { margin: 0 4px 3px 0; }
.target .desc {
  display: block;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  margin-top: 3px;
}

/* ---------- 选中详情 / 警示盒 ---------- */

.target-detail { margin-top: 16px; font-size: 14px; }
.target-detail:empty { display: none; }
.target-detail .detail-line { padding: 3px 0; }
.target-detail .coverage-list {
  margin: 6px 0 0 18px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 12px;
  columns: 2;
}
@media (max-width: 560px) { .target-detail .coverage-list { columns: 1; } }

.bed-warn, .oversize-warn {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid;
  border-left-width: 3px;
}
.bed-warn {
  border-color: rgba(242,189,74,.35);
  background: rgba(242,189,74,.07);
}
.oversize-warn {
  border-color: rgba(251,111,123,.4);
  background: rgba(251,111,123,.07);
}

/* ---------- 按钮 ---------- */

button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 15px;
  background: var(--accent);
  color: var(--accent-ink);
  transition: filter .15s, box-shadow .15s, transform .05s;
}
button:hover { filter: brightness(1.08); box-shadow: 0 8px 30px -10px var(--accent-glow); }
button:active { transform: translateY(1px); }
button:disabled {
  background: var(--accent-dim);
  color: rgba(233,241,249,.45);
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
button.secondary:hover { background: var(--bg-hover); filter: none; box-shadow: none; }
.btn-row { display: flex; gap: 12px; margin-top: 18px; }
.btn-row button { flex: 1; }

/* 转换进行态：喷嘴绘制刀路（按钮内联，宽度稳定） */
#convertBtn { min-height: 48px; }
.btn-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.btn-progress[hidden] { display: none; }
.mini-toolpath { width: 20px; height: 20px; }
.mini-toolpath path {
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 16 84;
  animation: plot 1.05s linear infinite;
}
@keyframes plot { to { stroke-dashoffset: -100; } }

/* ---------- 转换报告 ---------- */

.result-badge-row { margin-bottom: 4px; }
.summary-list { list-style: none; margin-top: 10px; font-size: 14px; }
.summary-list li { padding: 7px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.summary-list li:last-child { border-bottom: none; }
.summary-list .warn-line { color: var(--warn); }

/* CS-11 警告条目：详情区 warn-list 与报告 summary-list 共用 severity 描边着色 */
.warn-list { list-style: none; margin-top: 10px; font-size: 13.5px; }
.warn-list li { padding: 5px 0 5px 10px; border-left: 2px solid var(--line); color: var(--ink-dim); overflow-wrap: anywhere; }
.warn-list li.warn { border-left-color: var(--amber); color: var(--ink); }
.warn-list li.info { border-left-color: var(--accent); }
.summary-list li.warn, .summary-list li.info { padding-left: 10px; border-left: 2px solid var(--line); }
.summary-list li.warn { border-left-color: var(--amber); }
.summary-list li.info { border-left-color: var(--accent); }
.arrow { color: var(--accent); font-weight: 700; padding: 0 3px; font-family: var(--mono); }

code {
  background: rgba(79,200,245,.08);
  border: 1px solid rgba(79,200,245,.14);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}

/* ---------- 说明 / 图签栏页脚 ---------- */

.notes h2 { margin-bottom: 10px; }
.notes ul { color: var(--ink-dim); font-size: 13px; }
.notes li { margin-bottom: 8px; margin-left: 18px; }
.notes li::marker { color: var(--accent); }

.title-block {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--ink-faint);
}
.title-block .tb-note { color: var(--ink-dim); }
.build-stamp { flex: 0 0 100%; letter-spacing: .03em; }
.build-stamp:empty { display: none; }

.hidden { display: none !important; }

/* 全局焦点可见（键盘可达性） */
button:focus-visible,
#dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
  .container { padding-top: 28px; }
  .hero h1 { font-size: 31px; }
  .hero-toolpath { width: 120px; height: 120px; top: -18px; right: -14px; opacity: .11; }
  .btn-row { flex-direction: column; }
  .card { padding: 18px; }
}

/* ---------- 动效降级：一律呈现终态，不播放过程 ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .hero-toolpath path { stroke-dashoffset: 0; animation: none; }
  .mini-toolpath path { stroke-dasharray: 100; stroke-dashoffset: 0; animation: none; }
  .bed-ants rect { animation: none; }
}
