.battery-shell {
  display: grid;
  gap: 1rem;
  padding: 0 clamp(1rem, 5vw, 4rem) 4rem;
}

.safety-panel {
  display: grid;
  gap: 0.8rem;
}

.safety-panel h2,
.safety-panel p {
  margin: 0;
}

.safety-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.7rem;
}

.safety-grid span {
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(255, 190, 92, 0.28);
  border-radius: 16px;
  background: rgba(255, 190, 92, 0.08);
  color: #ffd399;
  font-size: 0.9rem;
  font-weight: 800;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.builder-controls {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 1rem;
}

.builder-controls h2,
.section-head h2 {
  margin: 0;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.builder-main {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}

.shape-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(31, 37, 51, 0.58);
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease;
}

.shape-card:hover,
.shape-card[aria-selected="true"] {
  border-color: rgba(124, 200, 255, 0.75);
  transform: translateY(-1px);
}

.shape-card h3,
.shape-card p {
  margin: 0;
}

.shape-card p,
.summary-card,
.instruction-output {
  color: var(--muted);
  line-height: 1.6;
}

.pack-drawing {
  position: relative;
  display: grid;
  gap: 0.35rem;
  align-content: center;
  justify-content: stretch;
  min-height: 7rem;
  padding: 2rem 0.75rem 0.75rem;
  border-radius: 16px;
  background: rgba(7, 16, 24, 0.72);
  overflow: hidden;
}

.pack-rows {
  display: grid;
  gap: 0.35rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.25rem;
  scrollbar-color: rgba(124, 200, 255, 0.55) transparent;
}

.pack-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  gap: 0.35rem;
  width: max-content;
  min-width: 100%;
}

.cell-dot {
  display: inline-grid;
  place-items: center;
  grid-template-rows: 0.55rem 1fr 0.55rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,0.42), transparent 18%),
    linear-gradient(135deg, #7cc8ff, #1e5577);
  color: #071018;
  font-size: 0.62rem;
  font-weight: 900;
}

.cell-terminal {
  font-size: 0.5rem;
  line-height: 1;
}

.cell-index {
  font-size: 0.52rem;
  line-height: 1;
}

.cell-dot.top-plus .cell-terminal.top,
.cell-dot.top-minus .cell-terminal.bottom {
  color: #07351f;
}

.cell-dot.top-minus .cell-terminal.top,
.cell-dot.top-plus .cell-terminal.bottom {
  color: #5d1010;
}

.cell-dot.top-minus {
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,0.42), transparent 18%),
    linear-gradient(135deg, #ffb4b4, #7b2b2b);
}

.cell-pouch {
  position: relative;
  grid-template-rows: 0.5rem 1fr;
  width: 2.35rem;
  height: 1.8rem;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 22%),
    linear-gradient(135deg, #b8c7d6, #4a5968);
  color: #071018;
}

.compact-cells .cell-dot {
  width: 1.3rem;
  height: 1.3rem;
  font-size: 0.54rem;
}

.compact-cells .cell-pouch {
  width: 1.75rem;
  height: 1.35rem;
}

.compact-cells .cell-terminal,
.compact-cells .cell-index,
.compact-cells .pouch-tabs span {
  font-size: 0.46rem;
}

.pouch-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem;
  width: 100%;
  padding: 0 0.25rem;
  transform: translateY(-0.25rem);
}

.pouch-tabs span {
  display: inline-grid;
  place-items: center;
  min-height: 0.68rem;
  border-radius: 4px 4px 2px 2px;
  background: #d8dee7;
  font-size: 0.54rem;
  font-weight: 900;
}

.pouch-plus-right .pouch-tabs span:last-child,
.pouch-plus-left .pouch-tabs span:first-child {
  color: #07351f;
}

.pouch-plus-right .pouch-tabs span:first-child,
.pouch-plus-left .pouch-tabs span:last-child {
  color: #5d1010;
}

.polarity-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.endpoint-badge {
  position: absolute;
  top: 0.55rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.endpoint-badge em {
  font-style: normal;
  opacity: 0.82;
}

.endpoint-plus {
  right: 0.55rem;
  background: rgba(52, 211, 153, 0.2);
  color: #8af3c6;
}

.endpoint-minus {
  left: 0.55rem;
  background: rgba(255, 125, 125, 0.18);
  color: #ffb4b4;
}

.power-legend {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(31, 37, 51, 0.62);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.power-legend b {
  color: var(--accent);
}

.summary-card {
  display: grid;
  gap: 0.5rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(31, 37, 51, 0.58);
}

.summary-card b,
.instruction-output b {
  color: var(--text);
}

.metric-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.35rem;
}

.instruction-output {
  display: grid;
  gap: 1rem;
}

.instruction-block {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(31, 37, 51, 0.48);
}

.instruction-block h3 {
  margin: 0;
  color: var(--accent);
}

.instruction-block ol,
.instruction-block ul {
  margin: 0;
  padding-left: 1.25rem;
}

.instruction-block li + li {
  margin-top: 0.35rem;
}

.warning-callout {
  border-color: rgba(255, 125, 125, 0.36);
  background: rgba(255, 125, 125, 0.08);
  color: #ffb4b4;
}

.topology {
  display: grid;
  gap: 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.node-line {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: rgba(7, 16, 24, 0.7);
  overflow-wrap: anywhere;
}

.step-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.75rem;
}

.step-visual {
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background: rgba(7, 16, 24, 0.58);
}

.step-visual p {
  margin: 0;
}

.step-title {
  color: var(--accent);
  font-weight: 900;
}

.mini-pack,
.series-demo,
.balance-demo,
.terminal-demo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  min-height: 3rem;
  padding: 0.6rem;
  border-radius: 14px;
  background: rgba(31, 37, 51, 0.76);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: rgba(124, 200, 255, 0.55) transparent;
}

.mini-cell {
  display: inline-grid;
  grid-template-rows: 0.7rem 1fr 0.7rem;
  place-items: center;
  width: 2rem;
  height: 2.8rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #7cc8ff, #1e5577);
  color: #071018;
  font-size: 0.66rem;
  font-weight: 900;
}

.series-cell {
  display: inline-grid;
  grid-template-rows: 0.65rem 1fr 0.65rem;
  place-items: center;
  width: 2.2rem;
  height: 3rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #7cc8ff, #1e5577);
  color: #071018;
  font-size: 0.68rem;
  font-weight: 900;
}

.series-cell.top-minus {
  background: linear-gradient(180deg, #ffb4b4, #7b2b2b);
}

.series-group,
.balance-node,
.terminal-badge {
  display: inline-grid;
  place-items: center;
  min-width: 2.4rem;
  min-height: 2rem;
  padding: 0.35rem 0.5rem;
  border-radius: 12px;
  background: rgba(124, 200, 255, 0.12);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.series-link {
  color: var(--accent);
  font-weight: 900;
}

.series-bridge {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 2.2rem;
  min-height: 1.8rem;
  border-radius: 999px;
  background: rgba(255, 190, 92, 0.14);
  color: #ffd399;
  font-size: 0.72rem;
  font-weight: 900;
}

.series-bridge::before,
.series-bridge::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0.6rem;
  height: 2px;
  background: rgba(255, 211, 153, 0.7);
}

.series-bridge::before {
  right: 100%;
}

.series-bridge::after {
  left: 100%;
}

.terminal-badge.plus {
  background: rgba(52, 211, 153, 0.18);
  color: #8af3c6;
}

.terminal-badge.minus {
  background: rgba(255, 125, 125, 0.15);
  color: #ffb4b4;
}

.terminal-demo {
  justify-content: space-between;
}

.solder-map {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 190, 92, 0.22);
  border-radius: 16px;
  background: rgba(255, 190, 92, 0.06);
}

.solder-map p {
  margin: 0;
}

.solder-step {
  display: grid;
  grid-template-columns: minmax(3rem, auto) minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: rgba(7, 16, 24, 0.56);
}

.solder-step b {
  color: var(--accent);
}

.solder-step span {
  overflow-wrap: anywhere;
}

@media (max-width: 920px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }

  .builder-controls {
    position: static;
  }
}

@media (max-width: 720px) {
  .battery-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .battery-hero .hero-card {
    justify-items: center;
  }

  .shape-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .battery-shell {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .battery-hero {
    padding: 1rem 0.75rem;
  }

  .inline-grid,
  .section-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .shape-card,
  .instruction-block,
  .summary-card {
    padding: 0.85rem;
  }

  .metric-line {
    display: grid;
  }

  .pack-drawing {
    padding: 2.4rem 0.55rem 0.65rem;
  }

  .endpoint-badge {
    font-size: 0.66rem;
    gap: 0.25rem;
    padding: 0.24rem 0.42rem;
  }

  .cell-dot {
    width: 1.45rem;
    height: 1.45rem;
  }

  .cell-pouch {
    width: 2.05rem;
    height: 1.65rem;
  }

  .solder-step {
    grid-template-columns: 1fr;
  }
}
