.view-tabs {
  position: absolute;
  z-index: 6;
  top: 95px;
  left: 18px;
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view-tab {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.view-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.08);
}

.view-tab.active,
.view-tab.view-action.primary {
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
}

.view-tab.view-action {
  background: var(--surface-2);
}

.canvas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  min-height: 0;
}

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  overflow: hidden;
}

.info-strip {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.info-strip div {
  padding: 12px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04);
}

.info-strip span,
.info-strip strong {
  display: block;
}

.info-strip span {
  color: var(--muted);
  font-size: 12px;
}

.info-strip strong {
  margin-top: 4px;
  font-size: 15px;
}

.drawing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.drawing-layout {
  min-height: 0;
  padding: 74px 18px 18px;
  overflow: auto;
}

.drawing-page {
  position: relative;
  display: block;
  width: 100%;
  height: min(72vh, 740px);
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.drawing-page::before {
  display: none;
}

.drawing-page #drawingSvg {
  position: relative;
  z-index: 1;
}

.print-header {
  display: none;
}

#previewSvg,
#drawingSvg,
#threeViewport {
  width: 100%;
  height: 100%;
  display: block;
}

#threeViewport {
  position: relative;
}

#threeViewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.view-cube {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  width: 112px;
  height: 112px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

#threeViewport .view-cube canvas {
  display: block;
  width: 112px !important;
  height: 112px !important;
  cursor: pointer;
  touch-action: none;
}

.shelf-part {
  fill: #ffffff;
  stroke: #1f2937;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.shelf-cutout {
  fill: url(#cutoutHatch);
  stroke: #ef4444;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.shelf-wire {
  fill: none;
  stroke-dasharray: none;
}

.dimension-line,
.extension-line,
.radius-line {
  stroke: #111;
  stroke-width: 1.2;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.extension-line {
  stroke-width: 0.8;
}

.dimension-arrow {
  fill: #111;
  stroke: none;
}

.dimension-text,
.radius-text,
.cutout-text {
  fill: #111827;
  font: 700 13px Inter, Arial, sans-serif;
}

.cutout-text {
  fill: #991b1b;
}

@media (min-width: 921px) and (max-width: 1500px) {
  .view-tabs {
    gap: 6px;
    padding: 5px;
  }

  .view-tab {
    min-height: 32px;
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 11px;
  }
}

@media (max-width: 920px) {
  .view-tabs {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
  }

  .view-tab {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 7px;
    font-size: 11px;
  }

  .view-tabs .view-action {
    display: none;
  }

  .canvas-layout {
    grid-template-columns: 1fr;
  }

  .info-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .drawing-actions {
    justify-content: stretch;
    margin-bottom: 12px;
  }

  .drawing-actions .button {
    flex: 1;
  }

  .drawing-layout {
    padding-bottom: 112px;
  }
}

@media print {
  @page {
    margin: 8mm;
  }

  html,
  body {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body > *:not(.app-shell),
  .sidebar,
  .topbar,
  .view-tabs,
  #modelView,
  #printBtn,
  #exportSvgBtn,
  #toast,
  #footerBar,
  #toTopBtn {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .drawing-layout,
  #drawingView {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .drawing-page {
    display: grid;
    grid-template-rows: 18mm 1fr;
    width: 100% !important;
    height: calc(100vh - 16mm) !important;
    margin: 0 !important;
    box-shadow: none;
    border: 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .drawing-page::before {
    display: none !important;
  }

  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12mm;
    padding: 0 0 4mm;
    border-bottom: 1px solid #d1d5db;
  }

  .print-header img {
    display: block;
    width: 52mm;
    height: 14mm;
    object-fit: contain;
  }

  .print-header div {
    display: grid;
    gap: 1mm;
    text-align: right;
    color: #111827;
    font-family: 'Inter', Arial, sans-serif;
  }

  .print-header strong {
    font-size: 14pt;
    line-height: 1.1;
  }

  .print-header span {
    font-size: 9pt;
    color: #4b5563;
  }

  #drawingSvg {
    width: 100% !important;
    height: 100% !important;
  }
}
