/* Fujitoyo Parts Finder — dense industrial parts-catalogue UI.
   One accent, hairlines, tabular numerals, no gradients, no shadows beyond the popup. */

:root {
  --bg:        #f2f1ee;
  --panel:     #ffffff;
  --panel-2:   #faf9f6;
  --ink:       #1b1d1c;
  --ink-2:     #565b59;
  --ink-3:     #848a87;
  --line:      #dcd9d3;
  --line-2:    #c3bfb7;
  --accent:    #c8401c;
  --accent-2:  #8f2c11;
  --accent-sf: #fbeae3;
  --mark:      #ffe9a8;
  --ok:        #1f6f4a;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, dl, dd, ol, ul, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; }
button, input { font: inherit; color: inherit; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--ink); color: #fff; padding: 8px 12px; font-size: 12px;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------------------------------------------------------- masthead */

.masthead {
  position: relative;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.masthead::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent);
}
.masthead-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding-top: 14px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; color: var(--ink); flex: none; }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong {
  font-size: 17px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
}
.brand-text span {
  font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-3);
}

.tally { display: flex; gap: 26px; flex-wrap: wrap; }
.tally div { display: flex; flex-direction: column; gap: 1px; }
.tally dt {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.tally dd { font-size: 13px; font-weight: 600; }

html[data-status="loading"] .masthead::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 30%;
  background: var(--accent); animation: sweep 1.3s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(433%); } }

/* ----------------------------------------------------------------- panels */

main { padding: 22px 0 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.panel + .panel { margin-top: 16px; }

.controls { padding: 16px 18px 18px; }
.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.eyebrow {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
  font-weight: 700; margin-bottom: 3px;
}
.panel-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }

.btn-reset {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 5px 10px; font-size: 11.5px; color: var(--ink-2); cursor: pointer;
}
.btn-reset svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.btn-reset:hover { border-color: var(--ink); color: var(--ink); }

/* ---------------------------------------------------------------- search */

.searchwrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 12px; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none;
}
.search-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; }
.search-input {
  width: 100%; height: 46px; padding: 0 42px 0 38px;
  background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 15px; letter-spacing: .01em;
}
.search-input::placeholder { color: var(--ink-3); }
.search-input:focus { background: var(--panel); border-color: var(--ink); outline: none; box-shadow: inset 0 0 0 1px var(--ink); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-clear {
  position: absolute; right: 8px; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--r); color: var(--ink-3); cursor: pointer;
}
.search-clear svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.search-clear:hover { color: var(--ink); background: var(--bg); }

.hint { margin-top: 7px; font-size: 11.5px; color: var(--ink-2); max-width: 92ch; }

/* ------------------------------------------------------------- cascades */

.cascades {
  display: grid; gap: 12px; margin-top: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.field[data-step] .field-label::before {
  content: attr(data-step);
  font-family: var(--mono); font-size: 9px; letter-spacing: 0;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 2px;
  width: 14px; height: 14px; display: grid; place-items: center; flex: none;
}
.field.has-value .field-label { color: var(--accent-2); }
.field.has-value .field-label::before { color: #fff; background: var(--accent); border-color: var(--accent); }

.cb { position: relative; }
.cb-input {
  width: 100%; height: 38px; padding: 0 30px 0 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 13.5px; text-overflow: ellipsis;
}
.cb-input::placeholder { color: var(--ink-3); font-size: 12.5px; }
.cb-input:hover:not(:disabled) { border-color: var(--ink-3); }
.cb-input:focus { background: var(--panel); border-color: var(--ink); outline: none; box-shadow: inset 0 0 0 1px var(--ink); }
.cb-input:disabled { background: #f6f5f2; color: var(--ink-3); border-style: dashed; cursor: not-allowed; }
.field.has-value .cb-input { border-color: var(--line-2); font-weight: 600; }

.cb-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  background: none; border: 0; border-radius: 2px; color: var(--ink-3); cursor: pointer;
}
.cb-clear svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.cb-clear:hover { color: var(--accent); background: var(--accent-sf); }

.cb-list {
  position: absolute; z-index: 30; top: calc(100% + 3px); left: 0; right: 0;
  max-height: 264px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--ink);
  box-shadow: 0 6px 16px rgba(27, 29, 28, .13);
}
.cb-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 6px 9px; font-size: 13px; cursor: pointer;
  border-left: 2px solid transparent;
}
.cb-opt + .cb-opt { border-top: 1px solid #f0eee9; }
.cb-opt.is-active { background: var(--accent-sf); border-left-color: var(--accent); }
.cb-opt[aria-selected="true"] .cb-opt-label { font-weight: 700; }
.cb-opt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-opt-n { font-size: 10.5px; color: var(--ink-3); flex: none; }
.cb-none, .cb-more {
  padding: 7px 9px; font-size: 11px; color: var(--ink-3); border-top: 1px solid #f0eee9;
}
.cb-more { background: var(--panel-2); }

.field-count {
  font-size: 10px; color: var(--ink-3); letter-spacing: .02em; min-height: 13px;
}
.field-note { font-size: 10px; color: var(--accent-2); }

/* --------------------------------------------------------------- results */

.results { overflow: hidden; }
.results-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 14px 18px 12px; border-bottom: 1px solid var(--line);
}
.results-title { font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.results-meta { font-size: 11px; color: var(--ink-3); }

.chips {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.chips-k {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  font-weight: 700; margin-right: 4px;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 3px 8px; font-size: 11.5px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent-2); background: var(--accent-sf); }
.chip-n { font-size: 10px; color: var(--ink-3); }
.chip:hover .chip-n { color: var(--accent-2); }

/* table rhythm — header and rows share one grid */
.thead, .row {
  display: grid;
  grid-template-columns:
    minmax(58px, .85fr) minmax(72px, 1.05fr) minmax(70px, 1fr)
    46px minmax(80px, .8fr) minmax(132px, 1.5fr) minmax(146px, 1.5fr);
  gap: 0 14px;
  align-items: center;
}
.thead {
  position: sticky; top: 0; z-index: 10;
  padding: 8px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
}
.thead .cell {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 700;
}
.row {
  padding: 7px 18px;
  border-bottom: 1px solid #efede8;
  font-size: 12.5px;
}
.row:nth-child(even) { background: var(--panel-2); }
.row:hover { background: var(--accent-sf); }
.cell { min-width: 0; overflow-wrap: anywhere; }
.c-year { font-size: 12px; }
.c-engine { color: var(--ink-2); font-size: 11.5px; }
.c-engine .cyl { font-weight: 600; color: var(--ink); }
.c-engine .sep { margin: 0 4px; color: var(--ink-3); }
.c-desc { color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
.c-part { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.dash { color: var(--line-2); }

.partno {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 2px 6px; cursor: pointer; text-align: left;
}
.partno-no { font-size: 12px; letter-spacing: .02em; font-weight: 600; }
.partno-ico { width: 11px; height: 11px; flex: none; opacity: 0; fill: none; stroke: var(--ink-3); stroke-width: 1.2; }
.partno:hover { border-color: var(--accent); background: var(--accent-sf); }
.partno:hover .partno-ico { opacity: 1; stroke: var(--accent-2); }
.partno.alt .partno-no { font-weight: 500; color: var(--ink-2); }
.partno[data-copied] { border-color: var(--ok); background: #eaf5ee; }
.partno[data-copied] .partno-ico { opacity: 1; stroke: var(--ok); }

mark { background: var(--mark); color: inherit; padding: 0; }

/* ------------------------------------------------------------------ states */

.state { padding: 34px 18px 40px; max-width: 68ch; }
.state-k {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); margin-bottom: 5px;
}
.state h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; letter-spacing: -.01em; }
.state p { font-size: 12.5px; color: var(--ink-2); max-width: 62ch; }
.state-detail { font-family: var(--mono); font-size: 11.5px; color: var(--accent-2); margin-top: 4px; }
.state-steps { margin: 6px 0 10px; counter-reset: s; }
.state-steps li {
  position: relative; padding-left: 24px; margin: 5px 0; font-size: 12.5px; color: var(--ink-2);
}
.state-steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 1px;
  width: 16px; height: 16px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 9px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 2px;
}
.state-hint { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }
.state-error { border-left: 3px solid var(--accent); }
.state-load h3 { color: var(--ink-2); }
code { font-family: var(--mono); font-size: .95em; background: var(--bg); padding: 1px 4px; border-radius: 2px; }

.results-foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.btn-more {
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--r);
  padding: 7px 14px; font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: .02em;
}
.btn-more:hover { background: var(--accent); border-color: var(--accent); }
.foot-note { font-size: 11px; color: var(--ink-3); }

/* ------------------------------------------------------------------ footer */

.sitefoot { padding-top: 18px; padding-bottom: 30px; }
.foot-line { font-size: 12px; color: var(--ink-2); }
.sitefoot .foot-note { margin-top: 4px; }

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 8px);
  background: var(--ink); color: #fff; font-size: 12px; padding: 8px 14px;
  border-radius: var(--r); opacity: 0; transition: opacity .14s ease, transform .14s ease;
  pointer-events: none; z-index: 60;
}
.toast[data-show] { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 980px) {
  .cascades { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .wrap { padding: 0 13px; }
  .masthead-in { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tally { gap: 16px 22px; }
  .panel-title { font-size: 18px; }
  .controls { padding: 14px 13px 15px; }
  .search-input { font-size: 14px; height: 42px; }
  .results-head { padding: 12px 13px 10px; }
  .chips { padding: 9px 13px; }
  .thead { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px; padding: 10px 13px;
  }
  .cell { display: flex; flex-direction: column; gap: 1px; }
  .cell::before {
    content: attr(data-label);
    font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 700;
  }
  .c-part { grid-column: 1 / -1; }
  .c-desc, .c-model { grid-column: span 2; }
  .row { border-bottom: 1px solid var(--line); }
  .row:nth-child(even) { background: var(--panel-2); }
  .results-foot { padding: 11px 13px; }
  .state { padding: 24px 13px 30px; }
}

@media (max-width: 400px) {
  .cascades { grid-template-columns: minmax(0, 1fr); }
  .tally div:nth-child(4) { display: none; }
  .brand-text strong { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-status="loading"] .masthead::after { animation: none; }
  .toast { transition: none; }
}

@media print {
  .masthead, .controls, .results-foot, .sitefoot, .toast { display: none; }
  .panel { border: 0; }
  .row { break-inside: avoid; }
}
