:root {
  --green: #16715a;
  --dark: #153331;
  --soft: #e9f3ed;
  --border: #dfe8e2;
  --muted: #61766c;
  --orange: #cf642b;
  font-family: Inter, Arial, sans-serif;
  color: var(--dark);
  background: #f4f7f4;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  max-width: 1080px;
  margin: auto;
  padding: 24px;
  line-height: 1.6;
}
a {
  color: var(--green);
  text-underline-offset: 4px;
}
h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.025em;
}
h1 {
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  margin: 8px 0 20px;
}
h2 {
  font-size: 1.5rem;
}
p {
  max-width: 76ch;
}
button,
.button,
.runner-download {
  display: inline-block;
  background: var(--green);
  color: white;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin: 4px 6px 4px 0;
}
button:hover,
.button:hover,
.runner-download:hover {
  background: #105541;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.secondary {
  background: var(--soft);
  color: var(--green);
  border-color: var(--border);
}
.secondary:hover {
  background: #d9ebdf;
}
input,
select,
textarea {
  font: inherit;
  color: var(--dark);
  border: 1px solid #becfc3;
  border-radius: 9px;
  padding: 11px;
  background: white;
  max-width: 100%;
}
input:not([type="checkbox"]):not([type="color"]):not([type="range"]),
select,
textarea {
  width: 100%;
  margin: 0 0 16px;
}
input[type="checkbox"] {
  width: auto;
  accent-color: var(--green);
  margin-right: 8px;
}
input[type="file"] {
  background: #f8fbf8;
  border-style: dashed;
}
label {
  display: block;
  font-weight: 600;
  margin-top: 14px;
  margin-bottom: 6px;
}
textarea {
  min-height: 140px;
  resize: vertical;
  font-size: 0.9rem;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #e4ac58;
  outline-offset: 3px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 18px;
}
.topbar div {
  display: flex;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  font-weight: 700;
}
.brand img {
  width: 70px;
  height: 56px;
  object-fit: contain;
  border-radius: 9px;
}
.hero {
  padding: 40px 0 24px;
}
.hero p {
  color: var(--muted);
}
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--green) !important;
}
.box,
#runner-panel,
.card {
  background: white;
  padding: 28px;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 5px 24px #18382a05;
}
.box h2,
#runner-panel h2 {
  margin-top: 0;
}
.hint,
.model-info {
  font-size: 0.9rem;
  color: var(--muted);
}
.preview {
  display: none;
  max-width: 100%;
  max-height: 500px;
  border-radius: 10px;
  margin: 15px 0;
}
.status,
#runner-message {
  margin-top: 14px;
  font-weight: 600;
}
.runner-error {
  color: #a32828;
}
#output {
  white-space: pre-wrap;
  background: #102e27;
  color: #e1f1e7;
  padding: 24px;
  border-radius: 12px;
  overflow: auto;
  min-height: 120px;
}
#runner-files {
  max-height: 300px;
  overflow: auto;
}
.runner-file {
  font-weight: 400;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
#runner-jobs {
  padding-left: 20px;
}
#runner-jobs li {
  margin: 16px 0;
  overflow-wrap: anywhere;
}
details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 15px 0;
}
summary {
  cursor: pointer;
  font-weight: 600;
}
code {
  overflow-wrap: anywhere;
}
#runner-panel {
  scroll-margin-top: 20px;
}
.steps,
.examples {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.steps .card,
.examples .card {
  margin: 0;
}
.number {
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--green);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-weight: 700;
}
.examples img {
  width: 100%;
  height: 210px;
  object-fit: contain;
  border-radius: 10px;
  background: #f4f5f0;
}
.examples .card {
  padding: 18px;
}
.image-controls {
  padding: 14px;
  background: #f5f9f6;
  border-radius: 12px;
  margin-bottom: 16px;
}
.image-controls label {
  font-size: 0.88rem;
  font-weight: 400;
}
.image-editor {
  width: min(1100px, 96vw);
  max-height: 95dvh;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  color: var(--dark);
}
.image-editor::backdrop {
  background: #08271fc9;
}
.image-editor header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.editor-toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.editor-toolbar label {
  font-size: 0.8rem;
  max-width: 220px;
  margin: 0;
}
.editor-toolbar input,
.editor-toolbar select {
  margin: 0 !important;
}
.canvas-wrap {
  background: #e7ece7;
  max-height: 60dvh;
  overflow: auto;
  border: 1px solid var(--border);
  margin-top: 16px;
}
.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}
.image-editor footer {
  display: flex;
  flex-wrap: wrap;
}
.image-editor h2 {
  margin: 0;
}
[hidden] {
  display: none !important;
}
@media (max-width: 650px) {
  body {
    padding: 14px;
  }
  .topbar {
    align-items: flex-start;
  }
  .topbar div {
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
  }
  .hero {
    padding: 25px 0 10px;
  }
  .box,
  #runner-panel,
  .card {
    padding: 20px;
  }
  .steps,
  .examples {
    grid-template-columns: 1fr;
  }
  .image-editor {
    padding: 12px;
  }
  .editor-toolbar {
    gap: 8px;
  }
  .editor-toolbar label {
    max-width: 135px;
  }
  .brand {
    gap: 8px;
    font-size: 0.9rem;
  }
}

/* Full-size examples remain readable on desktop and scale down on a phone. */
.examples {
  grid-template-columns: 1fr;
  gap: 28px;
}
.examples .card {
  padding: 24px;
}
.examples img {
  height: auto;
  max-height: 760px;
  object-fit: contain;
  background: #f4f7f4;
}
.examples h3 {
  font-size: 1.35rem;
}

/* Native details retain uploads and editor state when collapsed. */
.upload-panel > summary,
.history-panel > summary {
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
  color: #14563b;
  padding: 8px 0;
}
.upload-panel[open] > summary {
  margin-bottom: 18px;
}
.bounded-list,
#runner-files {
  max-height: 340px;
  overflow: auto;
  overflow-wrap: anywhere;
}
#output {
  max-height: 440px;
  overflow: auto;
}
.history-panel {
  margin: 20px 0;
}
.capture-preview {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  background: #edf4ef;
  border-radius: 12px;
}

.measurement-canvas { display:block; width:100%; height:auto; touch-action:none; border-radius:12px; background:#e7efe9; margin:16px 0; }
.measurement-canvas[hidden] { display:none; }
.window-result { display:flex; gap:16px; align-items:center; justify-content:space-between; padding:12px; border-bottom:1px solid #d5e4da; }
.window-result select { max-width:180px; }
.review-line { display:flex; gap:10px; align-items:flex-start; margin:18px 0; }
.review-line input { width:auto; margin-top:5px; }
#measurement-history { overflow-wrap:anywhere; }
#runner-jobs .button { display:inline-block; margin:10px 0; }
