:root {
  font: 16px/1.5 "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: #172535;
  background: #eef2f5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
header, .sheet-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
header { background: #172535; color: white; padding: 22px max(22px, calc((100% - 1400px) / 2)); }
header p { color: #c0cedb; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.print-help { margin-bottom: 10px !important; }
.mobile-nav { display: none; }
button, input, select { font: inherit; }
button { padding: 8px 14px; border-radius: 6px; border: 1px solid #8196aa; background: #273d52; color: white; cursor: pointer; }
button:last-child { background: #bbecdf; color: #142b32; border-color: #bbecdf; }
button:disabled { opacity: .55; cursor: default; }
main { display: grid; grid-template-columns: minmax(255px, 325px) minmax(0, 1fr); gap: 20px; max-width: 1444px; margin: 0 auto; padding: 22px; align-items: start; }
aside, article { padding: 20px; border: 1px solid #cdd8e1; border-radius: 10px; background: white; min-width: 0; }
aside > p, .note { color: #43576c; font-size: .875rem; margin-top: 8px; }
fieldset { padding: 8px 10px 12px; border: 1px solid #cdd8e1; border-radius: 6px; margin: 15px 0 0; min-width: 0; }
legend { font-weight: 650; padding: 0 5px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
label { font-size: .875rem; }
input, select { display: block; width: 100%; border: 1px solid #aebdca; padding: 5px 7px; border-radius: 4px; color: inherit; background: white; }
aside > label { display: block; margin-top: 10px; }
.fastener-toggle { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.fastener-toggle input { width: auto; }
input:disabled { background: #eef2f5; }
#error { color: #9d2421; font-weight: 600; }
.sheet-header { border-bottom: 2px solid #273d52; padding-bottom: 10px; margin-bottom: 10px; }
.views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.views section { border: 1px solid #dce4eb; padding: 8px; min-width: 0; }
.views section h3 { margin: 0 0 4px 6px; }
svg { display: block; width: 100%; }
#iso { cursor: grab; touch-action: none; user-select: none; }
#iso:active { cursor: grabbing; }
#iso:focus-visible { outline: 2px solid #32766b; outline-offset: 2px; }
.rotation-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 6px 0; }
.rotation-controls button { padding: 3px 7px; font-size: .875rem; }
.bom { margin-top: 15px; }
.spacing-section { margin-top: 12px; break-inside: avoid; }
.gap-diagrams { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 6px; }
.gap-diagrams section { border: 1px solid #dce4eb; padding: 5px 7px; }
.gap-diagrams p { color: #43576c; font-size: .875rem; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px; text-align: right; border-bottom: 1px solid #cdd8e1; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2), th:last-child, td:last-child { text-align: left; }
.table-scroll { overflow-x: auto; }
.drawing-settings { margin-top: 15px; }
.drawing-settings summary { cursor: pointer; font-weight: 650; }
.drawing-footer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.revision-block, .title-block { border: 1px solid #43576c; min-width: 0; }
.revision-block h3 { padding: 5px 8px; }
.title-projection { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.projection-symbol { flex: none; width: 64px; }
.title-block dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.title-block dl div { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 4px 7px; border-top: 1px solid #aebdca; }
.title-block dl div:nth-child(odd) { border-right: 1px solid #aebdca; }
.title-block dt { color: #43576c; }
.title-block dd { margin: 0; overflow-wrap: anywhere; }
.title-block .tolerance { grid-column: 1 / -1; border-right: 0 !important; }
.nail-schedule { margin-top: 14px; }
.nail-schedule td:nth-child(3), .nail-schedule td:nth-child(4) { overflow-wrap: anywhere; }
.drawing-footer td { overflow-wrap: anywhere; }
@media screen and (max-width: 750px) {
  header { padding: 14px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left)); }
  h1 { font-size: 1.4rem; }
  .mobile-nav {
    display: flex;
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 1;
    gap: 8px;
    padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    border-bottom: 1px solid #cdd8e1;
    background: #eef2f5;
  }
  .mobile-nav a {
    flex: 1;
    min-height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid #aebdca;
    border-radius: 6px;
    background: white;
    color: #172535;
    text-decoration: none;
  }
  #editor, #drawing, #error { scroll-margin-top: calc(70px + env(safe-area-inset-top)); }
  main {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  aside, article { padding: 12px; }
  .fields label { display: flex; flex-direction: column; justify-content: space-between; }
  input[type="number"], select { min-height: 44px; font-size: 16px; }
  .fastener-toggle { min-height: 44px; }
  .fastener-toggle input { width: 20px; height: 20px; }
  .actions button, .rotation-controls button { min-height: 44px; }
  .actions button { flex: 1 1 7.5rem; }
  .views { grid-template-columns: minmax(0, 1fr); }
  .preview-view { order: -1; }
  .table-scroll table { min-width: 510px; }
  .drawing-footer { grid-template-columns: 1fr; }
}
@page { size: A3 landscape; margin: 10mm 10mm 10mm 20mm; }
@media print {
  :root { background: white; font-size: 11px; }
  header, aside, .mobile-nav, .actions, .rotation-controls, .print-help, #size { display: none; }
  main { display: block; padding: 0; }
  article { border: 0; padding: 0; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sheet-header { margin-bottom: 1mm; padding-bottom: 1mm; }
  .assembly-sheet, .nail-schedule { border: .5mm solid #172535; padding: 3mm; }
  .views { grid-template-columns: repeat(2, 160mm); justify-content: space-between; gap: 1mm; break-inside: avoid; }
  .views section { border: 0; padding: 0; }
  .views section h3 { margin: 0; font-size: 10px; }
  .views svg { width: 160mm; }
  .spacing-section { display: none; }
  .drawing-footer, .bom { break-inside: avoid; }
  .drawing-footer, .bom, .note { margin-top: 2px; }
  .title-block dl div { padding: 2px 5px; }
  .nail-schedule { break-before: page; margin: 0; }
  .table-scroll { overflow: visible; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  th, td { padding: 1px 4px; }
  .orthographic .part-outline { stroke: #172535; stroke-width: .5mm; fill: white; vector-effect: non-scaling-stroke; }
  .orthographic .draft-line, .orthographic .draft-line path { stroke: #172535; stroke-width: .25mm; vector-effect: non-scaling-stroke; }
  .orthographic .hidden-edge { stroke-dasharray: 3mm 1mm; }
  .orthographic .center-line { stroke-dasharray: 6mm 1mm .6mm 1mm; }
}
