/* TOOLFLUX insert finder. Phone first, one tap per screen.
   Light workshop palette (bright shop light, one thumb). One dark moment: the grade reveal. */
:root {
  --paper: oklch(0.985 0.004 215);
  --panel: oklch(0.995 0.003 215);
  --ink: oklch(0.27 0.05 232);
  --ink-2: oklch(0.42 0.03 230);
  --muted: oklch(0.54 0.02 230);
  --line: oklch(0.9 0.008 220);
  --acc: oklch(0.62 0.105 215);
  --acc-press: oklch(0.52 0.1 218);
  --tint: oklch(0.955 0.025 210);
  --steel: oklch(0.89 0.012 230);
  --steel-2: oklch(0.79 0.014 230);
  --warn: oklch(0.82 0.13 75);
  --crit: oklch(0.56 0.19 27);
  /* ISO 513 application-group colours */
  --iso-P: oklch(0.55 0.15 255); --iso-M: oklch(0.86 0.16 95); --iso-K: oklch(0.57 0.19 27);
  --iso-N: oklch(0.62 0.13 150); --iso-S: oklch(0.72 0.15 60); --iso-H: oklch(0.6 0.012 250);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --display: 'Clash Grotesk', system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'Roboto Mono', Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { transition: background .45s var(--ease); }
body.dark { background: var(--ink); }
body.dark .back { color: var(--paper); }
body.dark .count { color: oklch(0.8 0.03 220); }
body.dark .track { background: oklch(0.36 0.04 232); }
body.dark .back:active { background: oklch(0.33 0.05 232); }
body { font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---- top bar + progress: a tool cutting across a bar of stock */
.bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 10px 12px 6px; }
.logo { justify-self: center; height: 22px; width: auto; }
.back { width: 44px; height: 44px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; border-radius: 22px; }
.back:active { background: var(--tint); }
.back[hidden] { display: grid; visibility: hidden; }
.ico-ui { width: 24px; height: 24px; }
.count { justify-self: end; font: 600 12px var(--mono); color: var(--muted); letter-spacing: .04em; }
.track { position: relative; height: 8px; margin: 0 16px; background: var(--steel); border-radius: 4px; overflow: visible; }
.track .cut { position: absolute; inset: 0; border-radius: 4px; transform-origin: left center; transform: scaleX(0); transition: transform .5s var(--ease);
  background: repeating-linear-gradient(90deg, var(--acc) 0 6px, var(--acc-press) 6px 8px); }
.track .tip { position: absolute; top: -6px; left: 0; width: 20px; height: 20px; transform: translateX(-10px); transition: transform .5s var(--ease); }
.ico-tip { width: 20px; height: 20px; display: block; animation: tipspin 2.4s linear infinite; }

/* ---- screens */
main { flex: 1; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow-y: auto; padding: 22px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.screen.enter { animation: inR .42s var(--ease) both; }
.screen.enter.rev { animation-name: inL; }
.screen.leave { animation: outL .3s var(--ease) both; pointer-events: none; }
.screen.leave.rev { animation-name: outR; }
.kicker { font: 600 12px var(--mono); letter-spacing: .08em; color: var(--acc-press); margin: 0 0 6px; }
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(28px, 8vw, 36px); line-height: 1.05; letter-spacing: -0.01em; margin: 0 0 18px; max-width: 18ch; }
.sub { color: var(--ink-2); margin: -10px 0 18px; max-width: 34ch; }
.grow { flex: 1; }

/* ---- tiles (one tap answers and moves on) */
.tile { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; transition: border-color .2s var(--ease), background .2s var(--ease), transform .1s; }
.tile:active { transform: scale(.98); }
.tile.on { border-color: var(--acc); background: var(--tint); }
.tile .t { font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1.1; }
.tile .h { color: var(--muted); font-size: 14px; }
.stack { display: grid; gap: 10px; }

/* product: three tall rows, picture first */
.product .tile { min-height: 148px; gap: 18px; }
.product .ico { width: 104px; height: 104px; flex: none; }
.product .tile .t { font-size: 24px; }
.ico-insert .spin { transform-box: fill-box; transform-origin: center; transition: transform .7s var(--ease); }
.tile.on .ico-insert .spin { transform: rotate(90deg); }
.ico-drill .flutes { animation: flute 1.2s linear infinite; animation-play-state: paused; }
.tile.on .ico-drill .flutes, .tile:hover .ico-drill .flutes { animation-play-state: running; }
.ico-holder .seat { transform-box: fill-box; transition: transform .5s var(--ease); }
.tile.on .ico-holder .seat { transform: translate(-2px, 2px); }

/* metal families: a 2-column grid; the ISO letter carries the standard colour */
.metals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metals .tile { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 132px; padding: 12px; }
.metals .ico { width: 64px; height: 64px; }
.iso { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font: 700 14px var(--mono); color: var(--paper); }
.iso.M { color: var(--ink); }
.metals .iso { position: absolute; top: 10px; right: 10px; }
.ico-metal .shine { animation: shine 2.6s var(--ease) infinite; }
.tile.on .ico-metal { animation: lift .5s var(--ease); }

/* WMG groups: ruled rows, like a chart */
.rows { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 46px 1fr 18px; gap: 10px; align-items: center; width: 100%; text-align: left; background: none;
  border: 0; border-bottom: 1px solid var(--line); padding: 14px 4px; min-height: 64px; transition: background .2s var(--ease); }
.row:active, .row.on { background: var(--tint); }
.row .code { font: 700 15px var(--mono); color: var(--ink); }
.row > span:nth-child(2) { min-width: 0; }
.row .n { font-weight: 600; }
.row .ex { display: block; font: 12px var(--mono); color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); }
.find { display: flex; gap: 8px; margin: 0 0 14px; }
.find input { flex: 1; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); font-size: 16px; min-width: 0; }
.find input:focus { border-color: var(--acc); outline: none; }
.hits { margin: -6px 0 14px; }
.hit { display: block; width: 100%; text-align: left; border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel); padding: 10px 12px; margin-bottom: 8px; }
.hit b { font-family: var(--mono); }
.note { color: var(--muted); font-size: 14px; }
.link { background: none; border: 0; color: var(--acc-press); font-weight: 600; padding: 12px 4px; text-align: left; }

/* operations: 2x2, each a tiny loop of the cut */
.ops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ops .tile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px 12px; }
.ico-op { width: 100%; height: auto; aspect-ratio: 3 / 2; background: var(--paper); border-radius: 10px; }
.op-turning .rot, .op-grooving .rot { animation: spinbar .9s linear infinite; }
.op-turning .tool { animation: feed 3.2s var(--ease) infinite; }
.op-turning .chip { animation: chip 3.2s ease-out infinite; transform-box: fill-box; }
.op-milling .cutter { transform-box: fill-box; transform-origin: center; animation: rot 1s linear infinite; }
.op-milling .traverse { animation: traverse 3.6s ease-in-out infinite alternate; }
.op-grooving .plunge { animation: plunge 2.4s var(--ease) infinite; }
.op-drilling .plunge-d { animation: plunge-d 2.8s var(--ease) infinite; }
.op-drilling .flutes { animation: flute-d .6s linear infinite; }

/* insert types: a 3-column grid of top views; picking one indexes it like a turn in the pocket */
.shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shapes .tile { flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 6px 12px; min-height: 112px;
  animation: pop .38s var(--ease) both; }
.shapes .tile:nth-child(3n+2) { animation-delay: .04s; }
.shapes .tile:nth-child(3n) { animation-delay: .08s; }
.shapes .ico-ins { width: 56px; height: 56px; margin-bottom: 4px; }
.shapes .tile .t { font: 700 15px var(--mono); letter-spacing: .02em; }
.shapes .tile .h { font-size: 12px; line-height: 1.25; }
.sgroup { grid-column: 1 / -1; margin: 10px 0 0; font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px; }
.sgroup::before { content: ''; width: 12px; height: 12px; border-radius: 3px; background: var(--warn); border: 1.5px solid var(--ink); }
.ico-ins .ins { transform-box: view-box; transform-origin: center; transition: transform .6s var(--ease); }
.tile.on .ico-ins .ins { transform: rotate(var(--turn, 90deg)); }
.find .use { border: 0; border-radius: 12px; padding: 0 18px; background: var(--acc); color: var(--paper); font-weight: 600; }

/* duty: the surface each leaves behind */
.duty .tile { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 14px 14px 0; overflow: hidden; }
.duty .ico-duty { width: calc(100% + 28px); height: 40px; margin: 6px -14px 0; display: block; }
.ico-duty .sheen { animation: sheen 2.4s 1.2s var(--ease) infinite; }
.ico-duty .draw { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: draw 1.1s var(--ease) forwards; }
.duty .tile:nth-child(2) .draw { animation-delay: .12s; }
.duty .tile:nth-child(3) .draw { animation-delay: .24s; }
.ico-duty .spark, .ico-metal .spark { transform-box: fill-box; transform-origin: center; animation: twinkle 2s ease-in-out infinite; }

/* ---- the reveal: the one dark screen */
.screen.reveal { background: var(--ink); color: var(--paper); }
.reveal .kicker { color: oklch(0.8 0.08 210); }
.reveal .sub { color: oklch(0.82 0.02 220); }
.gcard { position: relative; width: 100%; text-align: left; border-radius: 16px; padding: 18px 16px 16px; margin-bottom: 12px; overflow: hidden;
  background: oklch(0.33 0.05 232); border: 1.5px solid oklch(0.42 0.05 230); color: var(--paper);
  animation: deal .55s var(--ease) both; transition: border-color .2s var(--ease), background .2s var(--ease); }
.gcard:nth-of-type(2) { animation-delay: .12s; }
.gcard::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, oklch(1 0 0 / .14) 50%, transparent 70%);
  transform: translateX(-100%); animation: sweep 1.1s .45s var(--ease) both; pointer-events: none; }
.gcard.on { border-color: var(--acc); background: oklch(0.38 0.07 222); }
.gcard .line { font: 600 12px var(--mono); letter-spacing: .08em; color: oklch(0.8 0.08 210); }
.gcard .code { display: block; font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1.05; margin: 6px 0 8px; letter-spacing: .01em; }
.gcard .isos { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.gcard .iso { width: 24px; height: 24px; font-size: 13px; animation: pop .4s var(--ease) both; }
.gcard .iso:nth-child(2) { animation-delay: .5s; } .gcard .iso:nth-child(3) { animation-delay: .58s; } .gcard .iso:nth-child(1) { animation-delay: .42s; }
.gcard .coat { font: 12px var(--mono); color: oklch(0.82 0.02 220); margin-left: 6px; }
.gcard p { margin: 0; color: oklch(0.88 0.015 220); font-size: 15px; max-width: 40ch; }
.gcard .gnote { display: block; margin-top: 6px; font: 12px var(--mono); color: oklch(0.75 0.03 220); }
.reveal .link { color: oklch(0.82 0.08 210); }
.advise { border: 1.5px dashed oklch(0.5 0.04 230); border-radius: 16px; padding: 18px 16px; animation: deal .55s var(--ease) both; }
.advise b { font-family: var(--display); font-size: 22px; font-weight: 600; display: block; margin-bottom: 6px; }

/* ---- issues: chips with tiny pictures, pick any */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--panel); border-radius: 24px;
  padding: 8px 14px 8px 10px; min-height: 48px; transition: border-color .2s var(--ease), background .2s var(--ease), transform .1s; }
.chip:active { transform: scale(.96); }
.chip.on { border-color: var(--acc); background: var(--tint); font-weight: 600; }
.ico-issue { width: 28px; height: 28px; flex: none; }
.chip.on .ico-issue { animation: lift .4s var(--ease); }
.extras { margin-top: 18px; }
.extras summary { cursor: pointer; color: var(--acc-press); font-weight: 600; padding: 10px 0; list-style: none; }
.extras summary::-webkit-details-marker { display: none; }
.extras summary::before { content: '+ '; }
.extras[open] summary::before { content: '\2212  '; }
.photo { display: inline-flex; align-items: center; gap: 8px; border: 1.5px dashed var(--steel-2); border-radius: 12px; padding: 12px 14px; color: var(--ink-2); background: none; margin-top: 14px; }
.photo input { display: none; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs span { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--steel); display: grid; place-items: center; font: 700 11px var(--mono); color: var(--crit); animation: pop .3s var(--ease) both; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 11px; border: 0; background: oklch(0.27 0.05 232 / .75); color: var(--paper); font-size: 13px; line-height: 22px; padding: 0; }

/* ---- fields (contact) */
.fields { display: grid; gap: 12px; }
label.f { display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
label.f input, label.f textarea { border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px; background: var(--panel); font-size: 17px; font-weight: 400; color: var(--ink); width: 100%; }
label.f input:focus, label.f textarea:focus { border-color: var(--acc); outline: none; }
label.f.bad input { border-color: var(--crit); animation: nudge .3s var(--ease); }
.err { color: var(--crit); font-size: 14px; margin: 10px 0 0; min-height: 1.2em; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- the bottom action */
.act { position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom)); margin: 18px 0 calc(-24px - env(safe-area-inset-bottom)); padding: 10px 0 calc(16px + env(safe-area-inset-bottom)); background: var(--paper); z-index: 2; }
.act::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 22px; background: linear-gradient(to bottom, transparent, var(--paper)); pointer-events: none; }
.reveal .act { background: var(--ink); }
.reveal .act::before { background: linear-gradient(to bottom, transparent, var(--ink)); }
.go { width: 100%; border: 0; border-radius: 14px; padding: 16px; background: var(--acc); color: var(--paper); font-family: var(--display); font-weight: 600; font-size: 19px; transition: background .2s var(--ease), transform .1s; }
.go:active { transform: scale(.98); background: var(--acc-press); }
.go:disabled { opacity: .55; }
.fine { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }

/* ---- done */
.done { align-items: center; justify-content: center; text-align: center; }
.ico-tick { width: 96px; height: 96px; margin-bottom: 18px; animation: pop .5s var(--ease) both; }
.ico-tick .draw { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .6s .25s var(--ease) forwards; }
.rid { font: 700 22px var(--mono); letter-spacing: .04em; margin: 4px 0 10px; }
.done h1 { margin-left: auto; margin-right: auto; }
.done .sub { margin: 0 auto 20px; }
.nojs { padding: 20px; }

/* ---- motion */
@keyframes inR { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes inL { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes outL { to { opacity: 0; transform: translateX(-28px); } }
@keyframes outR { to { opacity: 0; transform: translateX(28px); } }
@keyframes tipspin { to { transform: rotate(360deg); } }
@keyframes flute { to { transform: translateX(-10px); } }
@keyframes flute-d { to { transform: translateY(7px); } }
@keyframes spinbar { to { transform: translateY(6px); } }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes feed { 0% { transform: translateX(10px); } 70%, 100% { transform: translateX(-34px); } }
@keyframes chip { 0%, 20% { opacity: 0; transform: scale(.4); } 40%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(6px, 6px); } }
@keyframes traverse { from { transform: translateX(-26px); } to { transform: translateX(26px); } }
@keyframes plunge { 0%, 100% { transform: translateY(8px); } 45%, 60% { transform: translateY(0); } }
@keyframes plunge-d { 0%, 100% { transform: translateY(-8px); } 50%, 65% { transform: translateY(4px); } }
@keyframes sheen { 0%, 100% { opacity: 0; } 40% { opacity: .9; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes twinkle { 0%, 100% { transform: scale(.6); opacity: .5; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes shine { 0% { transform: translateX(-18px); opacity: 0; } 30% { opacity: 1; } 60%, 100% { transform: translateX(26px); opacity: 0; } }
@keyframes lift { 0% { transform: translateY(0); } 40% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
@keyframes deal { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sweep { to { transform: translateX(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes nudge { 30% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ico-duty .draw, .ico-tick .draw { stroke-dashoffset: 0; }
}

/* ---- phones: bigger type and pictures, and the one-tap choices fill the screen instead of leaving the bottom third empty */
@media (max-width: 639px) {
  body { font-size: 17px; }
  .bar { grid-template-columns: 64px 1fr 64px; padding: 12px 12px 8px; }
  .logo { height: 30px; }
  .count { font-size: 15px; white-space: nowrap; }
  .track { height: 10px; border-radius: 5px; }
  .track .cut { border-radius: 5px; }
  .track .tip { top: -7px; width: 24px; height: 24px; transform: translateX(-12px); }
  .ico-tip { width: 24px; height: 24px; }
  .screen { padding-top: 24px; }
  .kicker { font-size: 14px; }
  h1 { font-size: clamp(32px, 9.4vw, 40px); margin-bottom: 20px; }
  .sub { font-size: 17px; }
  .tile .t { font-size: 22px; }
  .tile .h { font-size: 16px; }

  .product, .metals, .ops, .duty { flex: 1 0 auto; grid-auto-rows: 1fr; }
  .product .tile { min-height: 136px; }
  .product .ico { width: 120px; height: 120px; }
  .product .tile .t { font-size: 28px; }
  .metals .tile { min-height: 124px; padding: 14px; justify-content: space-between; }
  .metals .ico { width: 84px; height: 84px; }
  .iso { width: 30px; height: 30px; font-size: 16px; }
  .ops .tile { justify-content: space-between; }
  .ops .tile .t { font-size: 22px; }
  .duty .tile { align-content: space-between; }
  .duty .ico-duty { height: 52px; }

  .rows { flex: 1 0 auto; display: flex; flex-direction: column; }
  .row { flex: 1 0 auto; grid-template-columns: 52px minmax(0, 1fr) 18px; min-height: 72px; }
  .row .code { font-size: 17px; }
  .row .n { font-size: 18px; }
  .row .ex { font-size: 14px; }
  .find input { font-size: 17px; padding: 14px 16px; }

  .shapes { gap: 10px; }
  .shapes .tile { min-height: 132px; }
  .shapes .ico-ins { width: 68px; height: 68px; }
  .shapes .tile .t { font-size: 17px; }
  .shapes .tile .h { font-size: 13.5px; }
  .sgroup { font-size: 13px; }

  .chip { font-size: 17px; min-height: 52px; padding: 10px 16px 10px 12px; }
  .ico-issue { width: 32px; height: 32px; }
  .note { font-size: 15px; }
  .link { font-size: 17px; }
  label.f { font-size: 15px; }
  .go { font-size: 21px; padding: 18px; }
  .fine { font-size: 14px; }
  .gcard .code { font-size: 38px; }
  .gcard .line, .gcard .coat, .gcard .gnote { font-size: 13px; }
  .gcard p { font-size: 16px; }
}

@media (min-width: 640px) {
  .screen { padding-left: max(16px, calc(50% - 280px)); padding-right: max(16px, calc(50% - 280px)); }
  .track { margin: 0 max(16px, calc(50% - 280px)); }
}
