.pipe-model-library {
  display: grid;
  gap: 18px;
  margin-top: 16px;
  overflow: hidden;
}

.pipe-library-heading {
  align-items: end;
  gap: 18px;
}

.pipe-library-heading h3,
.pipe-model-stage-head h4,
.pipe-technical-copy h4 {
  margin: 3px 0 0;
}

.pipe-library-heading > div > p:last-child {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.pipe-model-search {
  display: grid;
  min-width: min(280px, 100%);
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pipe-model-search input {
  min-height: 44px;
}

.pipe-model-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  min-height: 620px;
}

.pipe-model-picker {
  display: grid;
  grid-auto-rows: minmax(58px, auto);
  align-content: start;
  gap: 8px;
  max-height: 720px;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pipe-model-option {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.pipe-model-option:hover,
.pipe-model-option:focus-visible {
  border-color: #38bdf8;
  transform: translateX(2px);
}

.pipe-model-option.active {
  border-color: #34d399;
  background: linear-gradient(135deg, rgba(16, 185, 129, .2), rgba(14, 116, 144, .15));
  box-shadow: inset 3px 0 #34d399;
}

.pipe-model-option strong {
  color: #fff;
  font-size: 18px;
}

.pipe-model-option span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.pipe-model-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
}

.pipe-model-stage-card {
  display: grid;
  grid-template-rows: auto minmax(390px, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: radial-gradient(circle at 50% 30%, #173744 0, #0b1b22 48%, #071116 100%);
}

.pipe-model-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, .2);
  background: rgba(5, 19, 25, .82);
}

.pipe-model-code {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: #0f766e;
  color: #ecfeff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}

.pipe-model-stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pipe-model-canvas-wrap {
  position: relative;
  min-height: 390px;
  touch-action: none;
  cursor: grab;
}

.pipe-model-canvas-wrap:active { cursor: grabbing; }

#pipeModelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.pipe-model-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 999px;
  background: rgba(2, 12, 17, .76);
  color: #e2e8f0;
  font-size: 12px;
  pointer-events: none;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.pipe-model-hint span { color: #67e8f9; font-size: 18px; }
.pipe-model-hint small { color: #94a3b8; }

.pipe-model-dimensions {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 1px;
  border-top: 1px solid rgba(148, 163, 184, .2);
  background: rgba(148, 163, 184, .15);
}

.pipe-model-dimension {
  min-width: 0;
  padding: 12px 13px;
  background: rgba(5, 19, 25, .92);
}

.pipe-model-dimension span,
.pipe-model-dimension strong { display: block; }
.pipe-model-dimension span { color: #94a3b8; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pipe-model-dimension strong { margin-top: 4px; color: #f8fafc; font-size: 14px; white-space: nowrap; }

.pipe-technical-panel {
  display: grid;
  grid-template-columns: minmax(250px, .55fr) minmax(0, 1.45fr);
  gap: 18px;
  align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pipe-technical-copy { display: grid; align-content: center; }
.pipe-technical-copy > p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); }

.pipe-drawing-preview-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: zoom-in;
}

.pipe-drawing-preview-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1.414 / 1;
  object-fit: contain;
  background: #fff;
}

.pipe-drawing-preview-button span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(3, 19, 18, .86);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.pipe-drawing-dialog {
  width: min(96vw, 1500px);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid #475569;
  border-radius: 18px;
  background: #071116;
  color: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .72);
}

.pipe-drawing-dialog::backdrop { background: rgba(0, 0, 0, .78); backdrop-filter: blur(5px); }

.pipe-drawing-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.pipe-drawing-dialog-head h3 { margin: 3px 0 0; }
.pipe-drawing-dialog > img { display: block; width: 100%; max-height: calc(94vh - 82px); object-fit: contain; background: #fff; }

@media (max-width: 1050px) {
  .pipe-model-layout { grid-template-columns: 1fr; min-height: 0; }
  .pipe-model-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: none; padding: 0; overflow: visible; }
  .pipe-model-dimensions { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .pipe-library-heading,
  .pipe-model-stage-head { align-items: stretch; flex-direction: column; }
  .pipe-model-search { width: 100%; }
  .pipe-model-picker { display: flex; padding-bottom: 5px; overflow-x: auto; scroll-snap-type: x proximity; }
  .pipe-model-option { flex: 0 0 174px; scroll-snap-align: start; }
  .pipe-model-stage-card { grid-template-rows: auto 390px auto; }
  .pipe-model-stage-actions { justify-content: flex-start; }
  .pipe-model-hint { width: max-content; max-width: calc(100% - 18px); }
  .pipe-model-hint small { display: none; }
  .pipe-model-dimensions { grid-template-columns: repeat(2, 1fr); }
  .pipe-technical-panel { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pipe-model-option { transition: none; }
}
