/* LDTILE / TMUL 交互波形共用样式。复用 npu-matmul-common.css 的卡片、按钮、L0 单元格等基础样式。 */

html, body { height: auto !important; overflow: visible !important; }
body.wave-page {
  background: var(--bg);
  color: var(--ink);
  overflow: visible;
  height: auto;
  font-size: 12.5px;
  zoom: var(--ui-zoom, 1.3);
  width: calc(100vw / var(--ui-zoom, 1.3));
}
.wave-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wave-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.wave-head .title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .2px;
}
.wave-head .title .accent { color: var(--a); }
.wave-head .sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.wave-head .wave-tip {
  font-size: 10.5px;
  color: #98a6b5;
  white-space: nowrap;
}
.wave-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 5px 9px;
}
.wave-controls .btn { padding: 3px 9px; font-size: 12px; }
.wave-controls .speed {
  height: 24px;
  border: 1px solid #cfd9e5;
  border-radius: 6px;
  background: #fff;
  color: #34495e;
  font-size: 11.5px;
}
.wave-controls .switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: #5d7084;
  white-space: nowrap;
}
.wave-controls .switch input { accent-color: var(--a); margin: 0; }
.cycle-label {
  font-family: var(--mono);
  font-size: 12px;
  color: #34495e;
  font-weight: 700;
  white-space: nowrap;
}
.wave-wrap .desc {
  min-height: 62px;
  font-size: 13px;
  line-height: 1.6;
  flex: none;
}
.wave-card { padding: 7px 9px 9px; }
.wave-scroll { overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.wave-table {
  display: grid;
  grid-template-columns: 156px repeat(var(--cycles, 7), minmax(34px, 1fr));
  gap: 2px;
  min-width: calc(156px + var(--cycles, 7) * 34px);
  align-items: stretch;
}
.wave-corner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-family: var(--mono);
  font-size: 9px;
  color: #aab6c4;
}
.wave-hcell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  border-radius: 3px;
  background: #f1f5f9;
  color: #7c8b9c;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.wave-hcell:hover { background: #e8eef5; }
.wave-hcell.cur {
  background: #fff3cd;
  color: #b9770e;
  box-shadow: inset 0 0 0 1px #f0b429;
}
.wave-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  height: 16px;
  margin-top: 2px;
  padding-left: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #8a97a7;
  letter-spacing: .4px;
  border-bottom: 1px solid #edf2f7;
}
.wave-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: #607286;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wave-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  border: 1px solid #edf2f7;
  border-radius: 3px;
  background: #fff;
  color: #40566a;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  position: relative;
}
.wave-cell:hover { border-color: #c9d8e6; }
.wave-cell.null { color: #d2dbe4; }
.wave-cell.cur {
  outline: 2px solid #f0b429;
  outline-offset: -1px;
  z-index: 1;
}
.wave-cell.bit1 { background: #e8f6ee; color: #1e8449; font-weight: 700; }
.wave-cell.bit0 { background: #f6f8fa; color: #aab6c4; }
.wave-cell.st-IDLE { background: #f1f5f9; color: #7c8b9c; }
.wave-cell.st-LOAD { background: #eaf3fa; color: #2471a3; font-weight: 700; }
.wave-cell.st-PRE { background: #f5ecf9; color: #7d3c98; font-weight: 700; }
.wave-cell.st-MUL { background: #eafaf1; color: #1e8449; font-weight: 700; }

.wave-hw-card { padding: 7px 9px 8px; }
.wave-hw {
  display: grid;
  gap: 7px;
  align-items: stretch;
}
.wave-hw.ld { grid-template-columns: max-content minmax(0, 1fr); max-width: 1020px; margin: 0 auto; }
.wave-hw.tm { grid-template-columns: max-content minmax(280px, 1fr) max-content; max-width: 1180px; margin: 0 auto; }
.wave-l0card, .wave-arrcard {
  border: 1px solid #e6edf4;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 5px 6px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.wave-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 3px;
  min-width: 0;
}
.wave-subhead .nm { font-family: var(--mono); font-weight: 800; font-size: 11.5px; }
.wave-subhead .nm.a { color: var(--a); }
.wave-subhead .nm.b { color: var(--b); }
.wave-subhead .nm.c { color: var(--c); }
.wave-subhead .nm.mul { color: #8e44ad; }
.wave-subhead .mini { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wave-matrix {
  display: grid;
  grid-template-columns: 38px repeat(var(--n, 4), var(--cs, 20px));
  gap: 2px;
  align-items: center;
  justify-content: center;
}
.wave-rowlabel {
  font-family: var(--mono);
  font-size: 8.5px;
  color: #9aa9b8;
  text-align: right;
  white-space: nowrap;
}
.wave-l0cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cs, 20px);
  height: 21px;
  border: 1px solid #e2e9f1;
  border-radius: 3px;
  background: #fff;
  font-family: var(--mono);
  font-size: 10px;
  color: #3c5063;
  overflow: hidden;
}
.wave-l0cell.a { background: var(--a-soft); }
.wave-l0cell.b { background: var(--b-soft); }
.wave-l0cell.c { background: var(--c-soft); font-size: 9px; }
.wave-l0cell.zero { color: #aebbc8; }
.wave-l0cell.read { outline: 2px solid #5dade2; outline-offset: -2px; }
.wave-l0cell.inject { outline: 2px solid #b07cc6; outline-offset: -2px; }
.wave-l0cell.write { outline: 2px solid #f0b429; outline-offset: -2px; }
.wave-l0cell.old { box-shadow: inset 0 0 0 1px #f5b7b1; }
.wave-note { margin-top: 3px; font-size: 9px; color: #9aa9b8; line-height: 1.4; text-align: center; }

.wave-arrcard { justify-content: flex-start; }
.wave-arrhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}
.wave-arrhead .mini { font-size: 9.5px; color: #7f8fa0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wave-arr {
  display: grid;
  grid-template-columns: 38px repeat(var(--n, 4), minmax(0, 1fr));
  grid-template-rows: 21px repeat(var(--n, 4), 52px) 24px;
  gap: 4px;
  align-items: stretch;
  min-height: 0;
}
.wave-top { grid-row: 1; grid-column: 2 / -1; display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 4px; }
.wave-left { grid-row: 2 / span var(--n, 4); grid-column: 1; display: grid; grid-template-rows: repeat(var(--n, 4), 1fr); gap: 4px; }
.wave-pes { grid-row: 2 / span var(--n, 4); grid-column: 2 / -1; display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); grid-template-rows: repeat(var(--n, 4), 1fr); gap: 4px; }
.wave-bottom { grid-row: calc(2 + var(--n, 4)); grid-column: 2 / -1; display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 4px; }
.wave-bub {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 21px;
  border: 1px solid #d7e2ec;
  border-radius: 4px;
  background: #fff;
  font-family: var(--mono);
  font-size: 9px;
  color: #64748b;
  overflow: hidden;
  white-space: nowrap;
}
.wave-bub.a { background: #edf6fc; border-color: #85c1e9; color: #2471a3; font-weight: 700; }
.wave-bub.b { background: #f9f2fc; border-color: #c39bd3; color: #7d3c98; font-weight: 700; }
.wave-bub.c { background: #eefaf3; border-color: #82e0aa; color: #1e8449; font-weight: 700; }
.wave-bub.dim { color: #cbd5df; background: #fbfcfe; border-color: #edf2f7; }
.wave-bub .sub { font-size: 7.5px; color: #9aa9b8; margin-left: 1px; }
.wave-pe {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  border: 1px solid #d7e2ec;
  border-radius: 4px;
  background: #fff;
  padding: 2px 3px;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.25;
  overflow: hidden;
  min-width: 0;
}
.wave-pe .pid { font-size: 7.5px; color: #aab6c4; }
.wave-pe .pb { color: #7d3c98; font-weight: 700; }
.wave-pe .pa { color: #2471a3; font-weight: 700; }
.wave-pe .ps { color: #1e8449; font-weight: 700; }
.wave-pe.act { border-color: #2980b9; background: #f4faff; box-shadow: 0 0 0 1px rgba(41,128,185,.12); }
.wave-pe.new { border-color: #e67e22; background: #fff8ec; }
.wave-arrnote { font-size: 9px; color: #9aa9b8; text-align: center; margin-top: 2px; }

@media (max-width: 720px) {
  .wave-wrap { padding: 6px; }
  .wave-head .wave-tip { display: none; }
  .wave-hw.ld { grid-template-columns: 1fr; }
  .wave-hw.tm { grid-template-columns: 1fr; }
  .wave-table { grid-template-columns: 128px repeat(var(--cycles, 7), minmax(32px, 1fr)); min-width: calc(128px + var(--cycles, 7) * 32px); }
  .wave-label { font-size: 8px; }
}

/* ============ 内嵌矩阵编辑面板 ============ */
.wave-editor { display: none; padding: 0; overflow: hidden; }
.wave-editor.open { display: block; }
.wave-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.wave-editor-body {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  align-items: start;
}
.wave-editor-side { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.wave-editor-side .side-block { border: 1px solid #e8eef5; border-radius: 8px; background: #fbfcfe; padding: 8px; }
.wave-editor-side .side-label { font-size: 10.5px; font-weight: 700; color: #93a2b1; letter-spacing: .4px; margin-bottom: 5px; text-transform: uppercase; }
.wave-editor-side .size-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.wave-editor-side .size-controls label { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 11.5px; color: #3c5266; font-weight: 700; }
.wave-editor-side .size-controls input { width: 46px; height: 25px; padding: 0 2px; border: 1px solid #d5dee8; border-radius: 5px; text-align: center; font-family: var(--mono); font-size: 12px; }
.wave-editor-side .tabs { display: flex; gap: 2px; background: #f1f5f9; border-radius: 6px; padding: 2px; margin: 0 0 6px; }
.wave-editor-side .tab { flex: 1; border: 0; background: transparent; border-radius: 4px; padding: 3px 4px; font-size: 11px; font-weight: 700; color: #6b7c8e; font-family: var(--mono); }
.wave-editor-side .tab.active { background: #fff; color: var(--a); box-shadow: 0 1px 2px rgba(30,60,90,.12); }
.wave-editor-side .edit-tools { display: flex; gap: 3px; flex-wrap: wrap; }
.wave-editor-side .edit-tools .btn { padding: 2px 7px; font-size: 11px; }
.wave-editor-side .editor-hint { font-size: 10.5px; color: #8a97a7; line-height: 1.5; margin-top: 5px; }
.wave-editor-side .edit-note { font-size: 10px; color: #aab6c4; margin-top: 3px; font-family: var(--mono); }
.wave-editor-side .error { font-size: 10.5px; color: var(--red); min-height: 0; margin-top: 3px; line-height: 1.4; }
.wave-editor-gridwrap {
  max-height: 430px;
  overflow: auto;
  background: #f7fafc;
  border: 1px solid #e8eef5;
  border-radius: 9px;
  padding: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  scrollbar-width: thin;
}
.wave-editor-gridwrap .edit-grid { width: max-content; margin: 0 auto; }
.wave-editor-gridwrap .board-label { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 9px; color: #aab6c4; background: #f1f5f9; border-radius: 3px; }
.wave-editor-gridwrap .board-label.corner { background: transparent; }
.wave-editor-gridwrap .edit-cell { width: 100%; height: 100%; border: 1px solid #dce5ef; border-radius: 3px; background: #fff; text-align: center; font-family: var(--mono); font-size: 13px; color: var(--ink); padding: 0; min-width: 0; }
.wave-editor-gridwrap .edit-cell:focus { outline: 2px solid #bfe0f5; border-color: #7fb3d5; position: relative; z-index: 2; }
.wave-editor-gridwrap .edit-cell.readonly { display: flex; align-items: center; justify-content: center; background: var(--c-soft); color: #4a6b58; border-color: #e2eee7; }
.wave-editor-gridwrap .edit-cell.readonly.zero { color: #c7d2cb; }
.wave-editor-gridwrap .edit-cell.readonly.big { font-size: 10px; }

@media (max-width: 720px) {
  .wave-editor-body { grid-template-columns: 1fr; }
  .wave-editor-side { display: grid; grid-template-columns: 1fr; }
  .wave-editor-gridwrap { max-height: 360px; }
}

.wave-check {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #abebc6;
  background: #eafaf1;
  color: #1e8449;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: help;
}
.wave-check.bad { border-color: #f5b7b1; background: #fdedec; color: #c0392b; }

/* LDTILE PE: 显示 b_in（PE 间传递）与 reg b（寄存器值） */
.wave-pe .pin,
.wave-pe .preg {
  display: flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
  font-size: 8.5px;
  line-height: 1.35;
}
.wave-pe .pin { color: #9aa9b8; }
.wave-pe .preg { color: #607286; }
.wave-pe .pin .flow { color: #b07cc6; font-weight: 800; font-size: 9px; }
.wave-pe .pin .val { color: #7d3c98; font-weight: 700; }
.wave-pe .preg .val { color: #7d3c98; font-weight: 800; }
.wave-pe .pin .val:empty::before,
.wave-pe .preg .val:empty::before { content: '·'; color: #cbd5df; font-weight: 400; }

/* L0C 读/写数据直接显示实际的一行数字，单元格内换行 */
.wave-cell.wrap {
  display: block;
  padding: 1px 2px;
  line-height: 1.2;
  font-size: 8px;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-align: center;
}
