:root {
  font: 16px system-ui, sans-serif;
  color: #17262a;
  background: #eef2f1;
  --line: #cbd7d4;
  --accent: #075c52;
}
* { box-sizing: border-box; }
body { margin: 0; }
.top {
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: #142c2e;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.brand { font-size: 1.2rem; font-weight: 750; display: block; }
.subtitle { color: #cbdedc; font-size: .85rem; }
main { max-width: 1440px; margin: auto; padding: clamp(.8rem, 3vw, 2rem); }
.project, .workspace, .measurements { display: grid; gap: 1rem; }
.project { grid-template-columns: 2fr 2fr 1fr; margin-bottom: 1rem; }
.workspace { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.panel { background: white; border: 1px solid var(--line); padding: 1rem; border-radius: 12px; min-width: 0; }
.heading, .toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.heading { justify-content: space-between; margin-bottom: 1rem; }
h1, h2, h3 { margin: 0; }
h1, h2 { font-size: 1.15rem; }
p { margin: .6rem 0; }
label { display: grid; gap: .3rem; font-size: .89rem; font-weight: 650; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; min-width: 0; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; }
button, .upload { border: 1px solid var(--line); background: white; border-radius: 6px; padding: .55rem .75rem; cursor: pointer; font-size: .88rem; }
.primary { background: var(--accent); color: white; border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed="true"] { background: #122f32; }
.upload { position: relative; }
.upload:focus-within { outline: 2px solid var(--accent); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; }
canvas { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; }
canvas.drawing { cursor: crosshair; touch-action: none; }
#instructions, #status, #empty, #count { color: #486164; font-size: .86rem; }
#status:empty { display: none; }
#findings { padding: 0; list-style: none; display: flex; gap: .4rem; flex-wrap: wrap; }
#form { display: grid; gap: .7rem; }
.measurements { grid-template-columns: 1fr 1fr; }
#report, #form[hidden] { display: none; }
@media (max-width: 720px) { .project, .workspace { grid-template-columns: 1fr; } }
@media print {
  @page { size: A4; margin: 15mm; }
  body, .top, .panel { background: white; color: black; }
  .top { padding: 0; }
  .subtitle { color: black; }
  main { padding: 10mm 0 0; }
  .workspace { display: block; }
  .project { grid-template-columns: 2fr 2fr 1fr; }
  .project input { border: 0; padding: 0; }
  .panel { padding: 0; border: 0; break-inside: avoid; }
  .panel canvas { max-height: 135mm; width: auto; max-width: 100%; object-fit: contain; }
  #print, .details, .toolbar, .upload, #instructions, #status { display: none; }
  #report { display: block; margin-top: 8mm; }
  #report article { break-inside: avoid; border-top: 1px solid #aaa; padding: 3mm 0; }
  #report p { overflow-wrap: anywhere; white-space: pre-wrap; }
}
[hidden] { display: none !important; }
.top a { color: white; }
.access { max-width: 440px; margin: 2rem auto 0; }
.access form { display: grid; gap: .8rem; margin-top: 1rem; }
.hint { color: #486164; font-size: .85rem; margin: 0; }
#inspections { padding: 0; margin: 0; list-style: none; }
#inspections li { display: grid; gap: .3rem; padding: .85rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
#inspections a { color: var(--accent); font-weight: 650; }
#inspections span, #email { font-size: .9rem; }
#email { overflow-wrap: anywhere; }
#editor-error { margin: 1rem; }
@media print { #back, #retry { display: none; } }
.settings { margin-top: 1rem; overflow-wrap: anywhere; }
.settings summary { cursor: pointer; font-weight: 700; }
.settings form { display: grid; gap: .65rem; max-width: 30rem; margin: 1rem 0; }
.settings li { margin: .6rem 0; }
.settings li .toolbar { margin-top: .3rem; }
#credential { padding: 1rem; background: #eef5f3; margin-bottom: 1rem; }

@media screen {
  :root { --ink: #162e3a; --accent: #105d68; --line: #cbd6da; color: var(--ink); background: #f3f5f5; font-family: Inter, system-ui, sans-serif; }
  .top { background: #102e3b; border-bottom: 4px solid #d7ac55; padding: .85rem max(4vw, calc((100vw - 1320px)/2)); flex-wrap: wrap; }
  .top > div:first-child { border-left: 3px solid #d7ac55; padding-left: .8rem; }
  .brand { letter-spacing: -.035em; }
  .top a { text-underline-offset: .25em; }
  main { max-width: 1380px; }
  .home { max-width: 1140px; }
  .panel, .project { background: white; border: 1px solid var(--line); border-radius: 12px; padding: clamp(1rem, 2.3vw, 2rem); box-shadow: 0 3px 12px #17374708; }
  h1, .editor-title { font-size: clamp(1.55rem, 3vw, 2.2rem); letter-spacing: -.045em; line-height: 1.15; }
  h2 { font-size: 1.24rem; letter-spacing: -.025em; }
  label { gap: .4rem; color: #304d59; }
  input, select, button, .upload { min-height: 44px; }
  button, .upload { font-weight: 650; color: var(--ink); }
  button:hover:not(:disabled), .upload:hover { background: #e6eff0; }
  .primary, .primary:hover:not(:disabled), button[aria-pressed="true"] { color: white; background: var(--accent); }
  .primary:hover:not(:disabled) { background: #104b55; }
  :focus-visible { outline: 3px solid #ad7115; outline-offset: 3px; }
  .access { display: grid; grid-template-columns: .85fr 1fr; max-width: 840px; padding: 0; overflow: hidden; margin: clamp(1rem,8vh,6rem) auto; }
  .access-fields { padding: clamp(1.5rem,4vw,3rem); }
  .access-art { background-color: #184553; background-image: linear-gradient(#ffffff12 1px, transparent 1px),linear-gradient(90deg,#ffffff12 1px,transparent 1px); background-size: 20px 20px; position: relative; display: grid; place-items: center; min-height: 110px; }
  .elevation { width: 64%; border: 2px solid #e3ece9; transform: skewY(-8deg); box-shadow: 8px 6px 0 #92afb0; }
  .elevation i { display: block; height: clamp(22px,4vw,48px); border-bottom: 2px solid #dce9e7; background: repeating-linear-gradient(90deg, transparent 0 20%,#afc6c6 20% 22%); }
  .access-art span { position: absolute; top: 52%; left: 48%; border-left: 28px solid #d7ac55; background: #f7d28a; padding: .2rem .45rem; font: bold .8rem monospace; }
  #sections { display: flex; gap: .25rem; flex-wrap: wrap; padding-bottom: .8rem; }
  #sections button { background: transparent; border: 0; }
  #sections [aria-current="page"] { background: #dce8e9; color: #084954; box-shadow: inset 0 -3px var(--accent); }
  #filter-label { max-width: 30rem; margin: 1.5rem 0; }
  #inspections li { padding: 0; }
  #inspections a { display: grid; gap: .35rem; padding: 1rem .6rem; text-decoration: none; }
  #inspections a:hover { background: #f1f6f5; text-decoration: underline; }
  #inspections span { color: #49616a; font-weight: 400; }
  #empty-list, #no-match, #empty { padding: 1rem; background: #f2f6f6; border-left: 3px solid #b5cacc; }
  .settings { margin: 0; }
  .settings h2 { margin-top: 1.6rem; }
  #users, #events { list-style: none; padding: 0; }
  #users li, #events li { border-top: 1px solid var(--line); padding: .85rem 0; }
  #message:not(:empty) { padding: .85rem; background: #ffefd1; border-radius: 6px; }
  .editor-title { margin: .25rem 0 1rem; }
  #editor .toolbar { align-items: end; }
  #instructions { margin: 1rem 0 .5rem; }
  #count { border-radius: 1rem; padding: .2rem .65rem; background: #e4eeee; font-weight: 700; }
  #form { border-top: 1px solid var(--line); padding-top: 1rem; }
  .upload:has(input:disabled) { opacity: .58; }
  .upload input:disabled { cursor: not-allowed; }
  #status:not(:empty) { border-left: 3px solid var(--accent); padding-left: .65rem; }
  @media(max-width:720px) {
    .access { grid-template-columns: minmax(0,1fr); }
    .elevation { width: 34%; }
    .top { padding: .85rem 1rem; }
    .toolbar { min-width: 0; }
    .top .toolbar { max-width: 100%; }
    .panel .toolbar label { flex: 1 1 8rem; }
    input, select, textarea { font-size: 1rem; }
  }
}
@media print { .editor-title { margin-bottom: 6mm; } }
#shape { min-width: 0; margin: 0; padding: 0; border: 0; }
#shape label { display: inline-flex; align-items: center; gap: .35rem; }
.canvas-frame { overflow: auto; max-width: 100%; }
@media screen {
  #shape legend { font-size: 1rem; font-weight: 650; margin-bottom: .4rem; }
  #shape label { min-height: 48px; padding: .55rem .75rem; border: 1px solid #87999f; border-radius: 6px; cursor: pointer; }
  #shape label:has(:checked) { background: #d9efec; border: 2px solid #145e60; }
  #shape input { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: #105d68; }
  #editor :is(label,button,.upload,#instructions,#empty,#status) { font-size: 1rem; }
  #editor :is(button,select,.upload) { min-height: 48px; }
  #instructions { padding: .8rem 1rem; border-left: 4px solid #176969; background: #edf5f3; color: #1a3f45; line-height: 1.5; }
  .canvas-frame { max-height: 70vh; border: 1px solid #82979c; border-radius: 8px; }
  .canvas-frame.expanded canvas { width: 175%; }
  canvas.drawing { touch-action: manipulation; }
  canvas:focus-visible { outline-offset: -4px; }
  .canvas-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
}
@media print { .canvas-actions { display: none; } .canvas-frame { overflow: visible; } }
#keyboard-help { display: none; }
@media screen { .canvas-frame:has(canvas.drawing) + #keyboard-help { display: block; } }
#library { margin-bottom: 1.3rem; }
#library > label { max-width: 22rem; }
#library fieldset { padding: 0; margin: .9rem 0; border: 0; }
#library legend { font-weight: 700; margin-bottom: .5rem; }
#stamps { display: grid; grid-template-columns: repeat(auto-fit,minmax(105px,1fr)); gap: .4rem; }
#stamps button { display: grid; justify-items: center; align-content: start; gap: .4rem; }
#stamps canvas { border: 0; width: 55px; height: 33px; }
#stage { position: relative; }
#selection { position: absolute; outline: 2px dashed #126768; pointer-events: none; }
#selection button { position: absolute; pointer-events: auto; padding: 0; width: 44px; height: 44px; min-height: 44px; border: 2px solid white; background: #105d68; color: white; font-size: 1.5rem; touch-action: none; }
#move { left: 0; top: 0; cursor: move; }
#resize { right: 0; bottom: 0; cursor: nwse-resize; transform: translate(55%,55%); }
@media screen { .canvas-frame.expanded #stage { width: 175%; } .canvas-frame.expanded canvas { width: 100%; } }
@media print { #library, #selection { display: none !important; } }
#plate-settings { margin: .8rem 0; }
#plate-settings summary { cursor: pointer; padding: .7rem 0; font-weight: 650; }
#plate-settings label { margin: .6rem 0; }
#plate { display: none; }
@media print {
  #editor .workspace { display: none; }
  #plate { display: block; margin-top: 6mm; break-inside: avoid; }
  #plate > div { display: flex; gap: 4mm; }
  #plate figure { flex: 1; min-width: 0; margin: 2mm 0; }
  #plate img, #plate canvas { width: 100%; height: 73mm; object-fit: contain; border: 1px solid #555; }
  #plate figcaption { font-size: 10pt; margin-top: 1mm; }
}
#parts { display:grid; grid-template-columns:repeat(auto-fit,minmax(95px,1fr)); gap:.4rem; }
#parts button { display:grid; justify-items:center; align-content:start; gap:.4rem; }
#parts canvas { width:55px; height:33px; border:0; }
#part-list { margin:.6rem 0; }
#layers,#history { margin: .8rem 0; }
#layers label { margin:.4rem 0; }
#layers input[type=checkbox] { min-height:0; width:1.2rem;height:1.2rem; }
#layers label:has([type=checkbox]) { display:inline-flex;align-items:center;gap:.4rem;padding:.4rem; }
#legend { font-size:.9rem;line-height:1.5; }
#history-list { max-height:16rem;overflow:auto;overflow-wrap:anywhere; }
.register { max-width:100%;overflow-x:auto;margin:.8rem 0; }
.register table,#report table { border-collapse:collapse;width:100%;font-size:.9rem; }
.register :is(td,th),#report :is(td,th) { padding:.35rem;text-align:left;border-bottom:1px solid #d1dcdc; }
#findings { display:table-row-group; }
#legend span,.report-legend span { display:inline-flex;align-items:center;gap:.35rem;margin:.3rem .6rem .3rem 0; }
#legend canvas,.report-legend canvas { width:40px;height:18px;border:0; }
@media screen {
 .workspace { grid-template-columns:minmax(180px,.72fr) minmax(0,2fr) minmax(260px,1fr); gap:.7rem; }
 .workspace>.panel {padding:clamp(.7rem,1vw,1.2rem);}
 .toolbox {min-width:0;}.toolbox summary {cursor:pointer;font-weight:650;margin-bottom:.6rem;}
 .toolbox .toolbar {display:grid;} .toolbox #parts,.toolbox #stamps {grid-template-columns:repeat(auto-fit,minmax(85px,1fr));}
 #deliverable {width:min(1000px,94vw);max-height:92vh;border:1px solid #91a5a6;border-radius:.7rem;color:var(--ink);}
 #deliverable::backdrop {background:#122b36aa;}
 #preview-body figure img,#preview-body figure canvas {width:auto;max-width:100%;max-height:55vh;}
 #preview-body article img {max-width:100%;max-height:16rem;} #preview-body table {border-collapse:collapse;margin:.6rem 0;width:100%;}
 #preview-body td,#preview-body th {text-align:left;padding:.35rem;border-bottom:1px solid #ccc;}
 .project {grid-template-columns:repeat(auto-fit,minmax(160px,1fr));}
 @media(max-width:1050px){.workspace {grid-template-columns:minmax(0,1fr) minmax(240px,.6fr);} .toolbox {grid-column:1/-1;} }
 @media(max-width:720px){.workspace {display:block;}.workspace>.panel{margin-bottom:.7rem;} }
}
@media print { #deliverable,.toolbox {display:none!important;} }
#inspections details summary {cursor:pointer;padding:.55rem;font-weight:650;}
#inspections details ul {list-style:none;padding-inline-start:clamp(.4rem,1.4vw,1.25rem);border-left:2px solid #cbdcda;}
