:root {
	--navy: #1e2a3a;
	--brass: #b08d57;
	--sand: #f6f2ec;
	--line: #e4ddd2;
	--ink: #1f2328;
	--muted: #5f6672;
	--ok: #2d6a2d;
	--bad: #8a1c12;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 17px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: #fff; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
a { color: var(--navy); }
h1 { font-family: "Questrial", sans-serif; font-weight: 400; color: var(--navy); font-size: 28px; line-height: 1.2; margin: 0 0 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--navy); }
.brand svg { width: 28px; height: 28px; }
.brand span { font-family: "Questrial", sans-serif; font-size: 18px; line-height: 1; display: flex; flex-direction: column; }
.brand small { font-family: "Inter", sans-serif; font-size: 11px; color: var(--muted); margin-top: 3px; }
.help { font-size: 14px; font-weight: 600; white-space: nowrap; }
.progress { height: 4px; background: var(--sand); }
.progress span { display: block; height: 100%; width: 0; background: var(--brass); transition: width .25s; }

.screen { flex: 1; padding: 20px 16px 24px; outline: none; }
.step-no { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 600; color: var(--brass); margin: 0 0 6px; }
.lead { font-size: 17px; color: #333; margin: 0 0 18px; }
.tip { font-size: 15px; color: var(--muted); background: var(--sand); border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; }
.tip:empty { display: none; }
.warn { font-size: 15px; color: var(--bad); background: #fbeeec; border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.err { color: var(--bad); font-weight: 600; font-size: 15px; min-height: 1em; margin: 14px 0 0; }
.need { padding-left: 20px; margin: 0 0 8px; }
.need li { margin-bottom: 8px; }

/* Choice grids */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 6px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; line-height: 1.25; min-height: 44px; }
.choice img { width: 100%; aspect-ratio: 1; object-fit: contain; mix-blend-mode: multiply; }
.choice .q { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--muted); }
.choice[aria-checked="true"] { border-color: var(--navy); background: var(--sand); box-shadow: inset 0 0 0 1px var(--navy); }
.washers { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }

/* Diagram + size input */
.diagram { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto 8px; }
.size { margin: 0 0 18px; }
.size-label { display: block; font-weight: 600; margin-bottom: 6px; }
.size-row { display: flex; align-items: center; gap: 10px; }
.size-row input { font: inherit; font-size: 28px; font-weight: 600; width: 110px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; text-align: center; color: var(--navy); }
.size-row input:focus { border-color: var(--navy); outline: none; }
.unit { color: var(--muted); }
.size-out { margin-left: auto; font-family: "Questrial", sans-serif; font-size: 26px; color: var(--brass); }
.fracs { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.fracs button { font: inherit; font-size: 17px; padding: 10px 0; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); cursor: pointer; min-height: 44px; }
.fracs button[aria-checked="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Photos */
.photo { margin: 16px 0 0; border: 2px dashed var(--line); border-radius: 14px; padding: 12px; }
.photo.has { border-style: solid; border-color: var(--ok); }
.photo-btn { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.cam { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; }
.cam svg { width: 26px; height: 26px; }
.photo-text { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); }
.photo-text strong { color: var(--ink); font-size: 16px; }
.photo img { display: none; margin-top: 10px; border-radius: 10px; max-height: 220px; width: auto; }
.photo.has img { display: block; }
.photo-status { display: block; font-size: 13px; color: var(--ok); margin-top: 6px; }
.photo input:focus-visible + .photo-btn .cam { outline: 3px solid var(--brass); outline-offset: 2px; }
.shot { border-radius: 12px; max-height: 240px; width: auto; margin: 0 auto 12px; }

/* Recognition result */
.ai { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.ai strong { font-size: 18px; color: var(--navy); font-weight: 600; }
.ai.found { background: #eef5ee; border: 1.5px solid #b9d6b9; }
.ai.unsure { background: #fbf3e6; border: 1.5px solid #ecd3a8; }
.ai.pending { background: var(--sand); flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.ai-label { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 600; color: var(--ok); }
.ai-next { color: var(--muted); font-size: 14px; }
.spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--navy); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 15px; margin: 0 0 14px; }
.field input, .field textarea { font: inherit; font-weight: 400; font-size: 16px; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; min-height: 48px; width: 100%; background: #fff; color: var(--ink); }
.field input:focus, .field textarea:focus { border-color: var(--navy); outline: none; }
.hp { position: absolute; left: -9999px; }

/* Review */
.review { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0; border-top: 1px solid var(--line); }
.review dt, .review dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
.review dt { color: var(--muted); font-size: 14px; padding-right: 12px; }
.review dd { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; min-width: 0; }
.review dd > span { min-width: 0; overflow-wrap: anywhere; }
.edit { flex: none; white-space: nowrap; font: inherit; font-size: 14px; color: var(--navy); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0 0 0 8px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0 0; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; flex: none; }
.turnstile { margin-top: 16px; }

.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; margin: 12px 0 16px; }
.done-mark svg { width: 36px; height: 36px; }

/* Bottom bar */
.foot { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.btn { font: inherit; font-weight: 600; font-size: 17px; min-height: 52px; padding: 12px 20px; border-radius: 999px; border: 2px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer; }
#next { flex: 1; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px 8px; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn[hidden] { display: none; }

@media (min-width: 561px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
@media (max-width: 360px) { .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fracs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } .progress span { transition: none; } }
