/*!
 * 晶圆良率与 Die 数计算器 · 样式
 * 作用域全部限定在 #wc-app，不污染主题。
 * 变量体系：亮色默认，body.dark 下整套覆盖（含 SVG）。
 */

#wc-app {
  /* 亮色 */
  --wc-card: #ffffff;
  --wc-ink: #141a24;
  --wc-ink2: #48546a;
  --wc-muted: #8794a8;
  --wc-line: #e2e8f0;
  --wc-line2: #eef2f7;
  --wc-blue: #2563eb;
  --wc-blue-bg: #eef4ff;
  --wc-blue-line: #c7d9ff;
  --wc-green: #0d9f6e;
  --wc-green-bg: #e9f8f1;
  --wc-amber: #d97706;
  --wc-amber-bg: #fef4e6;
  --wc-red: #dc2626;
  --wc-red-bg: #fdeceb;
  --wc-r: 14px;
  --wc-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px -18px rgba(16, 24, 40, .18);

  /* SVG */
  --wc-w1: #fdfefe;
  --wc-w2: #eef2f8;
  --wc-w3: #d6dfeb;
  --wc-wafer-line: #c9d3e0;
  --wc-wafer-inner: #f8fafd;
  --wc-edge-fill: rgba(245, 158, 11, .22);
  --wc-edge-line: rgba(217, 119, 6, .5);
  --wc-good-fill: rgba(59, 130, 246, .17);
  --wc-good-line: rgba(37, 99, 235, .55);
  --wc-bad-fill: rgba(239, 68, 68, .30);
  --wc-bad-line: rgba(220, 38, 38, .78);
  --wc-dash: #9aa8bd;

  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 4px 0 8px;
  color: var(--wc-ink);
  font-size: 14px;
  line-height: 1.65;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

body.dark #wc-app {
  --wc-card: rgba(255, 255, 255, .045);
  --wc-ink: #e8ecf3;
  --wc-ink2: #b3bccb;
  --wc-muted: #8b98ab;
  --wc-line: rgba(255, 255, 255, .13);
  --wc-line2: rgba(255, 255, 255, .07);
  --wc-blue: #7aa2ff;
  --wc-blue-bg: rgba(122, 162, 255, .14);
  --wc-blue-line: rgba(122, 162, 255, .3);
  --wc-green: #6ee7a0;
  --wc-green-bg: rgba(110, 231, 160, .12);
  --wc-amber: #f5c451;
  --wc-amber-bg: rgba(245, 196, 81, .12);
  --wc-red: #f87171;
  --wc-red-bg: rgba(248, 113, 113, .12);
  --wc-shadow: 0 1px 2px rgba(0, 0, 0, .22), 0 10px 30px -18px rgba(0, 0, 0, .5);

  --wc-w1: #2b323f;
  --wc-w2: #242b37;
  --wc-w3: #1b212c;
  --wc-wafer-line: #3d4657;
  --wc-wafer-inner: #1f2632;
  --wc-edge-fill: rgba(245, 158, 11, .16);
  --wc-edge-line: rgba(245, 196, 81, .45);
  --wc-good-fill: rgba(122, 162, 255, .18);
  --wc-good-line: rgba(122, 162, 255, .55);
  --wc-bad-fill: rgba(248, 113, 113, .24);
  --wc-bad-line: rgba(248, 113, 113, .75);
  --wc-dash: #5a6678;
}

/* ---------- 作用域内基础重置（压住主题对正文的默认样式） ---------- */
#wc-app *,
#wc-app *::before,
#wc-app *::after { box-sizing: border-box; }

/* grid/flex 子项默认 min-width:auto，会被 input 的固有宽度撑破容器 */
#wc-app .kpis > *,
#wc-app .params > *,
#wc-app .grid2 > *,
#wc-app .chip-inputs > *,
#wc-app .chip-cmp > *,
#wc-app .field > .row > * { min-width: 0; }

#wc-app h2,
#wc-app h3,
#wc-app h4 { margin: 0; padding: 0; font-weight: 650; line-height: 1.45; letter-spacing: -.01em; }
#wc-app h2 { display: block; font-size: 15px; }
#wc-app h3 { font-size: 11.5px; }
#wc-app h4 { font-size: 12px; }

/* 主题 content-style/sakura.css 给正文标题加了装饰：
   h2::after 是标题下方的高亮条，h3/h4/h5::after 是 "#" / ">" / "~"，
   都是给长文章小节导航用的。组件内的标题只是 UI 标签，一律清掉。
   注意 h2 的条在主题里靠 --theme-skin-matching 上色，
   本地预览没这个变量会看不见，必须到线上或补变量后才能验证。 */
#wc-app h2::after,
#wc-app h3::after,
#wc-app h4::after,
#wc-app h5::after { content: none !important; }

#wc-app p { margin: 0; }
#wc-app ul,
#wc-app ol { margin: 0; padding: 0; list-style: none; }

#wc-app table { width: 100%; border-collapse: collapse; border: 0; background: none; margin: 0; }
#wc-app th,
#wc-app td { border: 0; background: none; }

#wc-app button { font-family: inherit; cursor: pointer; }
#wc-app input,
#wc-app select {
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

/* ---------- KPI ---------- */
#wc-app .kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
#wc-app .kpi {
  background: var(--wc-card);
  border: 1px solid var(--wc-line);
  border-radius: var(--wc-r);
  padding: 16px 18px;
  box-shadow: var(--wc-shadow);
}
#wc-app .kpi .k { font-size: 11.5px; color: var(--wc-muted); font-weight: 600; letter-spacing: .02em; }
#wc-app .kpi .v {
  font-size: 29px; font-weight: 680; letter-spacing: -.03em; margin-top: 4px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
#wc-app .kpi .v small { font-size: 14px; font-weight: 600; color: var(--wc-muted); margin-left: 2px; }
#wc-app .kpi .d { font-size: 11.5px; color: var(--wc-muted); margin-top: 3px; }
#wc-app .kpi.accent {
  border-color: var(--wc-blue-line);
  background: linear-gradient(180deg, var(--wc-blue-bg), var(--wc-card));
}

/* ---------- 参数区 ---------- */
#wc-app .panel {
  background: var(--wc-card);
  border: 1px solid var(--wc-line);
  border-radius: var(--wc-r);
  box-shadow: var(--wc-shadow);
}
#wc-app .params {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 4px;
  margin-bottom: 16px;
}
#wc-app .pgroup { padding: 14px 16px; border-right: 1px solid var(--wc-line2); }
#wc-app .pgroup:last-child { border-right: none; }
#wc-app .pgroup h3 {
  color: var(--wc-muted); font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; margin-bottom: 10px;
}
#wc-app .field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; }
#wc-app .field:last-child { margin-bottom: 0; }
#wc-app .field label { font-size: 11.5px; color: var(--wc-ink2); font-weight: 550; }
#wc-app .field .row { display: flex; align-items: center; gap: 6px; }
#wc-app .field input,
#wc-app .field select {
  width: 100%;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--wc-line);
  border-radius: 8px;
  background: var(--wc-card);
  font-size: 13px;
  color: var(--wc-ink);
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
#wc-app .field select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238794a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 26px;
}
#wc-app .field input:focus,
#wc-app .field select:focus {
  outline: none;
  border-color: var(--wc-blue);
  box-shadow: 0 0 0 3px var(--wc-blue-bg);
}
#wc-app .field .unit { font-size: 11px; color: var(--wc-muted); white-space: nowrap; flex: 0 0 auto; }
#wc-app .chk {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--wc-ink2); cursor: pointer; font-weight: 550;
}
#wc-app .chk input { width: 15px; height: 15px; accent-color: var(--wc-blue); cursor: pointer; flex: 0 0 auto; }

/* ---------- Tabs ---------- */
#wc-app .tabs {
  display: flex; gap: 4px; background: var(--wc-line2);
  padding: 4px; border-radius: 11px; width: fit-content; margin-bottom: 16px;
}
#wc-app .tabs button {
  border: none; background: transparent; padding: 7px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--wc-ink2); transition: .15s;
}
#wc-app .tabs button.on { background: var(--wc-card); color: var(--wc-ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .1); }
#wc-app .tab { display: none; }
#wc-app .tab.on { display: block; }

/* ---------- 卡片 ---------- */
#wc-app .card {
  background: var(--wc-card);
  border: 1px solid var(--wc-line);
  border-radius: var(--wc-r);
  box-shadow: var(--wc-shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
#wc-app .card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; flex-wrap: wrap; }
/* 标题不许被右侧提示挤成两行 */
#wc-app .card-h h2 { white-space: nowrap; flex: 0 0 auto; }
#wc-app .card-h .hint { font-size: 11.5px; color: var(--wc-muted); text-align: right; }
#wc-app .grid2 { display: grid; grid-template-columns: 1.05fr 1fr; gap: 16px; margin-bottom: 16px; }
#wc-app .grid2 > .card { margin-bottom: 0; }

/* ---------- 表格 ---------- */
#wc-app .kv td {
  padding: 8px 0; border-bottom: 1px solid var(--wc-line2);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
#wc-app .kv tr:last-child td { border-bottom: none; }
#wc-app .kv td:first-child { color: var(--wc-ink2); }
#wc-app .kv td:last-child { text-align: right; font-weight: 620; }
#wc-app .kv td .sub { display: block; font-weight: 400; font-size: 11px; color: var(--wc-muted); margin-top: 1px; }

#wc-app table.data { font-size: 12.5px; }
#wc-app table.data th {
  text-align: left; font-weight: 600; font-size: 11px; color: var(--wc-muted);
  letter-spacing: .03em; text-transform: uppercase; padding: 6px 8px;
  border-bottom: 1px solid var(--wc-line);
}
#wc-app table.data td { padding: 7px 8px; border-bottom: 1px solid var(--wc-line2); }
#wc-app table.data tr:last-child td { border-bottom: none; }
#wc-app table.data td.num { text-align: right; }
#wc-app table.data tr.hl td { background: var(--wc-blue-bg); font-weight: 620; }

/* ---------- 良率条 ---------- */
#wc-app .ybar { display: grid; grid-template-columns: 96px 1fr 52px; align-items: center; gap: 10px; margin-bottom: 9px; }
#wc-app .ybar .k { font-size: 12px; color: var(--wc-ink2); font-weight: 550; }
#wc-app .ybar .track { height: 9px; background: var(--wc-line); border-radius: 99px; overflow: hidden; }
#wc-app .ybar .track i { display: block; height: 100%; border-radius: 99px; transition: width .25s ease; }
#wc-app .ybar .v { font-size: 12.5px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
#wc-app .ybar.best .track i { box-shadow: 0 0 0 1px var(--wc-blue-line); }
#wc-app .ybar.best .v { color: var(--wc-blue); }

#wc-app .note {
  margin-top: 12px; padding: 9px 11px; background: var(--wc-line2);
  border-radius: 8px; font-size: 11.5px; color: var(--wc-ink2); line-height: 1.65;
}
#wc-app .note b { font-weight: 650; color: var(--wc-ink); }

/* ---------- 术语提示 ---------- */
#wc-app .term { position: relative; display: inline-flex; align-items: center; cursor: help; white-space: nowrap; }
#wc-app .term .q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 4px; border-radius: 50%;
  background: var(--wc-line2); color: var(--wc-muted);
  font-size: 9px; font-weight: 800; font-style: normal; line-height: 1;
  transition: .15s; flex: 0 0 auto;
}
#wc-app .term:hover .q { background: var(--wc-blue); color: #fff; }
#wc-app .term::after {
  content: attr(data-tip);
  position: absolute; left: 50%; top: calc(100% + 9px); transform: translate(-50%, -5px);
  background: #1b2432; color: #eef2f7; font-size: 11.5px; line-height: 1.62; font-weight: 400;
  padding: 8px 11px; border-radius: 8px; width: max-content; max-width: 252px;
  box-shadow: 0 10px 28px -10px rgba(16, 24, 40, .55);
  opacity: 0; visibility: hidden; pointer-events: none; transition: .16s ease; z-index: 90;
  white-space: normal; text-align: left; letter-spacing: 0;
}
#wc-app .term:hover::after { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#wc-app .term.tl::after { left: 0; transform: translate(0, -5px); }
#wc-app .term.tl:hover::after { transform: translate(0, 0); }
#wc-app .term.tr::after { left: auto; right: 0; transform: translate(0, -5px); }
#wc-app .term.tr:hover::after { transform: translate(0, 0); }

/* 靠左边界的位置改左对齐，避免浮层被裁 */
#wc-app .kpi:first-child .term::after,
#wc-app .kv td:first-child .term::after,
#wc-app .ybar .k .term::after,
#wc-app .params .pgroup:first-child .term::after { left: 0; transform: translate(0, -5px); }
#wc-app .kpi:first-child .term:hover::after,
#wc-app .kv td:first-child .term:hover::after,
#wc-app .ybar .k .term:hover::after,
#wc-app .params .pgroup:first-child .term:hover::after { transform: translate(0, 0); }

/* ---------- 迷你按钮 ---------- */
#wc-app .mini {
  border: 1px solid var(--wc-line); background: var(--wc-card); border-radius: 7px;
  width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--wc-ink2); font-size: 12px; flex: 0 0 auto; padding: 0; transition: .15s; line-height: 1;
}
#wc-app .mini:hover { border-color: var(--wc-blue); color: var(--wc-blue); background: var(--wc-blue-bg); }
#wc-app .mini:active { transform: scale(.94); }
#wc-app .priceref { font-size: 10.5px; color: var(--wc-muted); margin-top: 3px; font-variant-numeric: tabular-nums; line-height: 1.4; }

/* ---------- 警示 ---------- */
#wc-app .alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.55; margin-top: 12px; }
#wc-app .alert .ic { flex: 0 0 auto; font-weight: 700; font-size: 14px; }
#wc-app .alert.warn { background: var(--wc-amber-bg); color: var(--wc-amber); border: 1px solid var(--wc-amber-bg); }
#wc-app .alert.bad { background: var(--wc-red-bg); color: var(--wc-red); border: 1px solid var(--wc-red-bg); }
#wc-app .alert.ok { background: var(--wc-green-bg); color: var(--wc-green); border: 1px solid var(--wc-green-bg); }
#wc-app .alert b { font-weight: 700; }

/* ---------- SVG ---------- */
#wc-app .wafer-svg { width: 100%; height: auto; display: block; max-width: 480px; margin: 0 auto; }
#wc-app svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
#wc-app .chart text { font-family: inherit; font-variant-numeric: tabular-nums; }
#wc-app .chart .grid { stroke: var(--wc-line2); stroke-width: 1; }
#wc-app .chart .axis { stroke: var(--wc-line); stroke-width: 1; }
#wc-app .chart .tick { fill: var(--wc-muted); font-size: 10.5px; }
#wc-app .chart .axis-label { fill: var(--wc-muted); font-size: 10.5px; font-weight: 600; }
#wc-app .chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#wc-app .chart .dot { stroke: var(--wc-card); stroke-width: 1.5; }

#wc-app .w-base { fill: url(#wc-grad); stroke: var(--wc-wafer-line); stroke-width: 1; }
#wc-app .w-inner { fill: var(--wc-wafer-inner); stroke: none; }
#wc-app .w-notch { fill: var(--wc-wafer-inner); stroke: var(--wc-wafer-line); stroke-width: 1; }
#wc-app .w-dash { fill: none; stroke: var(--wc-dash); stroke-width: 1; stroke-dasharray: 3 4; opacity: .75; }
#wc-app .w-s1 { stop-color: var(--wc-w1); }
#wc-app .w-s2 { stop-color: var(--wc-w2); }
#wc-app .w-s3 { stop-color: var(--wc-w3); }
#wc-app .w-edge { fill: var(--wc-edge-fill); stroke: var(--wc-edge-line); }
#wc-app .w-good { fill: var(--wc-good-fill); stroke: var(--wc-good-line); }
#wc-app .w-bad { fill: var(--wc-bad-fill); stroke: var(--wc-bad-line); }

#wc-app .legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; font-size: 11.5px; color: var(--wc-ink2); }
#wc-app .legend span { display: flex; align-items: center; gap: 6px; }
#wc-app .legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
#wc-app .lstat { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; font-size: 11.5px; color: var(--wc-muted); margin-top: 7px; font-variant-numeric: tabular-nums; min-height: 24px; }
#wc-app .lstat b { color: var(--wc-ink); font-weight: 650; }
#wc-app .lstat b.r { color: var(--wc-red); }
#wc-app .lstat b.y { color: var(--wc-amber); }

/* 小按钮：重新模拟（不能用 .mini，那是价格重置的 25×25 图标按钮） */
#wc-app .reroll {
  appearance: none; border: 1px solid var(--wc-line); background: var(--wc-card);
  color: var(--wc-ink2); border-radius: 6px; padding: 3px 9px;
  font-size: 11px; line-height: 1.5; font-weight: 550; cursor: pointer;
  flex: 0 0 auto; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
#wc-app .reroll:hover { border-color: var(--wc-blue); color: var(--wc-blue); background: var(--wc-blue-bg); }
#wc-app .reroll:active { transform: translateY(1px); }

/* 朝向对照读数 */
#wc-app .oriline {
  font-size: 11.5px; color: var(--wc-ink2); font-variant-numeric: tabular-nums;
  padding-top: 5px; line-height: 1.5;
}
#wc-app .oriline .dim { color: var(--wc-muted); }

/* ---------- die 动画 ---------- */
#wc-app .wafer-svg rect.die {
  transform-box: fill-box;
  transform-origin: center;
  animation-fill-mode: both;
  cursor: crosshair;
  transition: transform .15s cubic-bezier(.2, .8, .3, 1), filter .15s ease;
}
#wc-app .wafer-svg rect.die:hover {
  transform: scale(1.18);
  filter: drop-shadow(0 3px 7px rgba(16, 24, 40, .38)) brightness(1.08);
  stroke-width: 1.6;
}
@keyframes wc-die-in { from { opacity: 0; transform: scale(.55); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  #wc-app .wafer-svg rect.die { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ---------- 紫光扫描（模拟光刻机曝光） ----------
   旋转 -45° 的竖直光带沿本地 x 轴平移 = 视觉上从左下扫向右上。
   周期 10s，其中前 1.7s 扫过，其余时间停在圆外不可见。
   延迟 2.5s：等开场的 die 点亮（约 1.4s）结束后再过 1s 才起第一轮。 */
#wc-app .w-uv0 { stop-color: #7e22ce; stop-opacity: 0; }
#wc-app .w-uv1 { stop-color: #a855f7; stop-opacity: .10; }
#wc-app .w-uv2 { stop-color: #9333ea; stop-opacity: .42; }

/* 不加 mix-blend-mode：screen 叠在近白的晶圆上会被「加亮」成纯白，等于不可见 */
#wc-app .wc-uv-band {
  /* fill-mode: both 是必需的：动画有 2.5s 延迟，没有 backwards 时
     延迟期间元素停在静态位置（圆正中）且 opacity 默认为 1，
     页面一加载就能看到一条紫带凭空挂在中间。 */
  animation: wc-uv-sweep 10s linear 2.5s infinite both;
  opacity: 0;
  will-change: transform;
}

@keyframes wc-uv-sweep {
  0%    { transform: translateX(-560px); opacity: 0; }
  1.5%  { opacity: 1; }
  16%   { transform: translateX(560px); opacity: 1; }
  18%   { transform: translateX(560px); opacity: 0; }
  100%  { transform: translateX(560px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #wc-app .wc-uv { display: none; }
}

/* ---------- 芯粒详情浮层 ---------- */
#wc-die-tip,
#wc-die-tip *,
#wc-die-tip *::before,
#wc-die-tip *::after { box-sizing: border-box; }

#wc-die-tip {
  position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none;
  background: #182130; color: #eef2f7; border-radius: 10px; padding: 10px 13px;
  font-size: 11.5px; line-height: 1.65; box-shadow: 0 14px 36px -12px rgba(10, 16, 26, .6);
  min-width: 168px; will-change: transform;
}
#wc-die-tip[hidden] { display: none; }
#wc-die-tip .dt-h {
  font-weight: 680; font-size: 12px; margin-bottom: 7px; padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .13); display: flex; align-items: center; gap: 6px;
}
#wc-die-tip .dt-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
#wc-die-tip .dt-row { display: flex; justify-content: space-between; gap: 18px; font-variant-numeric: tabular-nums; }
#wc-die-tip .dt-row span { color: #94a3b8; }
#wc-die-tip .dt-row b { font-weight: 620; color: #f4f7fb; }
#wc-die-tip .dt-note {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .1);
  color: #8fa0b6; font-size: 10.5px; line-height: 1.5;
}

/* ---------- Tornado ---------- */
#wc-app .tor { width: 100%; }
#wc-app .tor-row { display: grid; grid-template-columns: 110px 1fr 96px; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 12px; }
#wc-app .tor-row .lab { color: var(--wc-ink2); font-weight: 550; }
#wc-app .tor-row .bar-wrap { position: relative; height: 16px; background: var(--wc-line); border-radius: 4px; }
#wc-app .tor-row .bar-wrap::before {
  content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px;
  width: 1px; background: var(--wc-line);
}
#wc-app .tor-row .bar { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
#wc-app .tor-row .bar.lo { right: 50%; background: var(--wc-blue-line); }
#wc-app .tor-row .bar.hi { left: 50%; background: var(--wc-blue); }
#wc-app .tor-row .rng { text-align: right; font-size: 11px; color: var(--wc-muted); font-variant-numeric: tabular-nums; }

/* ---------- 热图 ---------- */
#wc-app .heat-wrap { display: flex; gap: 14px; align-items: stretch; }
#wc-app .heat-grid {
  flex: 1; display: grid; gap: 1.5px; border-radius: 8px;
  overflow: hidden; background: var(--wc-line2); padding: 1.5px;
}
#wc-app .heat-grid i { aspect-ratio: 2.4/1; display: block; transition: transform .1s; }
#wc-app .heat-y {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10.5px; color: var(--wc-muted); padding: 2px 0;
  text-align: right; font-variant-numeric: tabular-nums;
}
#wc-app .heat-x {
  display: flex; justify-content: space-between; font-size: 10.5px;
  color: var(--wc-muted); margin-top: 6px; padding: 0 2px; font-variant-numeric: tabular-nums;
}
#wc-app .heat-scale { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--wc-muted); margin-top: 12px; }
#wc-app .heat-scale .bar {
  height: 9px; width: 170px; border-radius: 99px;
  background: linear-gradient(90deg, #e8f5ee, #a7e2c4, #fee090, #fc8d59, #c51b3a);
}

/* ---------- Chiplet ---------- */
#wc-app .chip-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#wc-app .chip-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--wc-line); border-radius: 10px; overflow: hidden; }
#wc-app .chip-cmp > div { padding: 14px 16px; }
#wc-app .chip-cmp > div:first-child { border-right: 1px solid var(--wc-line); background: var(--wc-line2); }
#wc-app .chip-cmp h4 { color: var(--wc-muted); font-weight: 650; letter-spacing: .03em; text-transform: uppercase; margin-bottom: 10px; }
#wc-app .chip-cmp .big { font-size: 24px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
#wc-app .chip-cmp .big small { font-size: 12px; font-weight: 550; color: var(--wc-muted); }
#wc-app .chip-cmp .line { font-size: 12px; color: var(--wc-ink2); margin-top: 5px; display: flex; justify-content: space-between; }
#wc-app .chip-cmp .line b { font-weight: 640; color: var(--wc-ink); font-variant-numeric: tabular-nums; }

#wc-app .read {
  padding: 14px 16px; background: var(--wc-line2);
  border: 1px solid var(--wc-line); border-radius: 10px;
  font-size: 13px; line-height: 1.75; color: var(--wc-ink2);
}
#wc-app .read b { color: var(--wc-ink); font-weight: 650; }
#wc-app .read .hl { color: var(--wc-blue); font-weight: 650; }

#wc-app .foot { text-align: center; color: var(--wc-muted); font-size: 11.5px; padding: 22px 0 4px; line-height: 1.9; }
#wc-app .foot .warn-line { color: var(--wc-amber); }

/* ---------- 响应式：按组件自身宽度判断，而不是视口 ----------
 * WordPress 正文区常只有 700–900px，视口却是 1400px，
 * 用 @media 会把 5 列参数挤成一团，所以这里用容器查询。
 */
#wc-app { container-type: inline-size; }

@container (max-width: 1000px) {
  #wc-app .params { grid-template-columns: repeat(3, 1fr); }
  #wc-app .pgroup:nth-child(3) { border-right: none; }
}
@container (max-width: 820px) {
  #wc-app .chip-inputs { grid-template-columns: 1fr 1fr; }
}
@container (max-width: 620px) {
  #wc-app .chip-cmp { grid-template-columns: 1fr; }
  #wc-app .chip-cmp > div:first-child { border-right: none; border-bottom: 1px solid var(--wc-line); }
}
@container (max-width: 720px) {
  #wc-app .grid2 { grid-template-columns: 1fr; }
  #wc-app .kpis { grid-template-columns: repeat(2, 1fr); }
  #wc-app .params { grid-template-columns: repeat(2, 1fr); }
  #wc-app .pgroup { border-right: none; border-bottom: 1px solid var(--wc-line2); }
  #wc-app .tor-row { grid-template-columns: 86px 1fr 78px; font-size: 11px; }
}
@container (max-width: 520px) {
  #wc-app .kpis { grid-template-columns: 1fr; }
  #wc-app .kpi .v { font-size: 25px; }
  #wc-app .tabs { width: 100%; }
  #wc-app .tabs button { flex: 1; padding: 7px 8px; font-size: 12px; }
}

/* 不支持容器查询的旧浏览器：退回视口断点 */
@supports not (container-type: inline-size) {
  @media (max-width: 1000px) {
    #wc-app .params { grid-template-columns: repeat(3, 1fr); }
    #wc-app .pgroup:nth-child(3) { border-right: none; }
  }
  @media (max-width: 820px) {
    #wc-app .chip-inputs { grid-template-columns: 1fr 1fr; }
    #wc-app .chip-cmp { grid-template-columns: 1fr; }
  }
  @media (max-width: 720px) {
    #wc-app .grid2 { grid-template-columns: 1fr; }
    #wc-app .kpis { grid-template-columns: repeat(2, 1fr); }
    #wc-app .params { grid-template-columns: repeat(2, 1fr); }
    #wc-app .pgroup { border-right: none; border-bottom: 1px solid var(--wc-line2); }
    #wc-app .tor-row { grid-template-columns: 86px 1fr 78px; font-size: 11px; }
  }
}

/* ============================================================
   页面级全宽
   ------------------------------------------------------------
   主题 .site-content 固定 max-width:860px（内宽 820px），
   是为长文阅读留的版心。本工具需要更宽的工作区，
   由 shortcode 的 wide 属性（默认开）给 body 加 .wc-wide-page，
   只放宽这一个页面。断点以下保持主题原样。
   ============================================================ */
@media (min-width: 1000px) {
  body.wc-wide-page .site-content {
    max-width: min(1280px, calc(100vw - 48px));
  }
  body.wc-wide-page #wc-app {
    max-width: 1200px;
  }
}
