:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2b6cb0;
  --hot: #d9480f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 28px 48px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.shape {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.shape span { background: #e8edf4; padding: 2px 8px; border-radius: 4px; }
.shape i { font-style: normal; color: #9aa3b2; }

main {
  display: grid;
  grid-template-columns: 420px 210px minmax(320px, 1fr);
  gap: 16px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 16px;
}

.panel.wide { grid-column: 1 / -1; }

.net-panel { padding-bottom: 8px; }
#net {
  width: 100%;
  height: 720px;
  display: block;
}
#net text { pointer-events: none; }
#net g.node { cursor: pointer; }
#net g.node:hover rect.border { stroke: var(--accent); stroke-width: 1.6; }
#net image.fmap { image-rendering: pixelated; }

.panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
}

.panel h3 {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

#pad {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #cfd6e0;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

#input28 {
  width: 168px;
  height: 168px;
  image-rendering: pixelated;
  background: #000;
  border-radius: 6px;
  display: block;
}

.row { display: flex; gap: 8px; margin-top: 10px; }

button {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  background: #eef1f6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: #e3e8f0; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #245e9c; }

.presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.presets button {
  padding: 0;
  background: #fff;
  border: 1px solid var(--line);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.presets canvas { width: 42px; height: 42px; image-rendering: pixelated; }

.meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, Menlo, monospace;
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: #8a929f;
  line-height: 1.5;
}

.pred {
  font-size: 56px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
  min-height: 62px;
}

.layer-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 8px;
}
.layer-head h2 { margin: 0; }
.spec { font-size: 12px; color: #9aa3b2; }

#insp {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, .58);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
}
#insp.hidden { display: none; }

.insp-box {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px 20px;
  max-width: 1020px;
  max-height: 92vh;
  overflow: auto;
}

.insp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}
.insp-head button { flex: none; padding: 5px 12px; }

.insp-body { display: flex; gap: 24px; }
.insp-col { flex: none; }
.insp-col:last-child { min-width: 300px; }

.insp-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-family: ui-monospace, Menlo, monospace;
}

.insp-wrap { position: relative; width: 336px; height: 336px; }
#insp-input {
  width: 336px;
  height: 336px;
  image-rendering: pixelated;
  background: #000;
  border-radius: 6px;
  display: block;
  cursor: crosshair;
}

.win-box {
  position: absolute;
  border: 2px solid var(--hot);
  box-sizing: border-box;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .6) inset;
}

.insp-tip { font-size: 11px; color: #9aa3b2; margin-top: 6px; }

.insp-out-wrap { position: relative; width: 168px; height: 168px; }
#insp-out {
  width: 168px;
  height: 168px;
  image-rendering: pixelated;
  background: #000;
  border-radius: 6px;
  display: block;
  border: 1px solid #d5dae2;
}
.out-cell {
  position: absolute;
  border: 2px solid var(--hot);
  box-sizing: border-box;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .7) inset;
}

.kernel {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  gap: 4px;
}
.kernel.two { grid-template-columns: repeat(2, 56px); }
.kernel div {
  height: 56px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 11px/1 ui-monospace, Menlo, monospace;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.calc {
  font: 12px/1.7 ui-monospace, Menlo, monospace;
  min-width: 300px;
}
.calc .line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; color: #4a5361; }
.calc .line.head { color: #9aa3b2; font-size: 11px; border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-bottom: 3px; }
.calc .sum {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}
.calc .out { color: var(--hot); font-weight: 700; }
