/* OES Alloy Identifier — "scientific instrument, light".
   System fonts only (offline, no unverified CDN). OKLCH palette, WCAG AA. */

:root {
  /* surfaces & ink */
  --bg: oklch(1 0 0);
  --surface: oklch(0.984 0.003 250);
  --surface-sunken: oklch(0.968 0.004 250);
  --border: oklch(0.912 0.005 250);
  --border-strong: oklch(0.842 0.006 250);
  --ink: oklch(0.268 0.013 256);
  --ink-muted: oklch(0.486 0.013 256);
  --ink-faint: oklch(0.566 0.012 256);

  /* accent (does all the work) */
  --accent: oklch(0.546 0.166 256);
  --accent-hover: oklch(0.486 0.17 256);
  --accent-weak: oklch(0.95 0.03 256);
  --on-accent: oklch(1 0 0);

  /* semantic */
  --warn: oklch(0.52 0.13 47);
  --warn-weak: oklch(0.96 0.03 60);
  --warn-border: oklch(0.8 0.09 60);
  --err: oklch(0.52 0.18 25);
  --err-weak: oklch(0.96 0.04 25);
  --err-border: oklch(0.80 0.12 25);

  /* compliance verdict — sober green / sober red, same L-band as --accent */
  --pass: oklch(0.50 0.12 150);
  --pass-weak: oklch(0.95 0.052 150);
  --pass-border: oklch(0.80 0.08 150);
  --fail: oklch(0.52 0.15 27);
  --fail-weak: oklch(0.962 0.035 27);
  --fail-border: oklch(0.82 0.085 27);

  /* type */
  --sans: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", "Roboto Mono", monospace;

  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 28px; --s7: 40px;
  --radius: 6px;
  --radius-sm: 4px;

  /* z-index scale (semantic, no magic numbers) */
  --z-base: 1;
  --z-sticky: 100;

  --ring: 0 0 0 3px color-mix(in oklch, var(--accent) 35%, transparent);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: min(1080px, 92vw); margin-inline: auto; }

::selection { background: var(--accent-weak); }

/* ---------- masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: var(--s4); padding: var(--s5) 0; }
.brand__mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--on-accent);
  background: var(--accent);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}
.masthead h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand__sub { margin: 2px 0 0; color: var(--ink-muted); font-size: 13px; }

/* ---------- panels ---------- */
main { padding: var(--s6) 0 var(--s2); display: grid; gap: var(--s5); }
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: clip;
}
.panel__head { padding: var(--s5) var(--s5) 0; }
.panel__head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
}
.panel__deco {
  width: 80px;
  height: 80px;
  object-fit: contain;
  opacity: 1;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}
.panel__head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
.hint { margin: var(--s2) 0 0; color: var(--ink-muted); font-size: 13px; max-width: 70ch; }

/* ---------- database selector ---------- */
.silo-select {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  margin-top: var(--s5);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.silo-select__label {
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}
.seg {
  display: inline-flex; background: var(--surface-sunken);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 2px;
}
.seg button {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-muted); background: transparent;
  border: 0; padding: 6px 14px; cursor: pointer; border-radius: 3px;
  transition: background 160ms ease-out, color 160ms ease-out;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg button:focus-visible { outline: none; box-shadow: var(--ring); }
.silo-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* ---------- input grid ---------- */
form { padding: var(--s5); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: var(--s3);
}
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field label {
  font-size: 12px; color: var(--ink-muted);
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2);
}
.field label .sym { font-family: var(--mono); font-weight: 600; color: var(--ink); font-size: 13px; }
.field label .w { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.field input {
  font-family: var(--mono); font-size: 14px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 9px; width: 100%;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.field input:hover { border-color: var(--ink-faint); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field input::placeholder { color: var(--ink-faint); }
.field input.input--err { border-color: var(--err-border); background: var(--err-weak); }
.field input.input--err:focus { border-color: var(--err); box-shadow: 0 0 0 3px color-mix(in oklch, var(--err) 30%, transparent); }
.field__err { font-size: 10px; color: var(--err); min-height: 14px; display: block; }


/* ---------- actions / buttons ---------- */
.actions { display: flex; gap: var(--s3); margin-top: var(--s5); flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border-strong);
  transition: background 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.btn:hover { border-color: var(--ink-faint); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(0.5px); }
.btn--primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { color: var(--ink-faint); border-style: dashed; }
.btn--ghost:hover { color: var(--ink-muted); border-color: var(--ink-faint); border-style: dashed; }
.form-error { margin: 0; padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
  background: var(--err-weak); color: var(--err); font-size: 13px; border: 1px solid var(--err-border); }

/* ---------- results ---------- */
.warning {
  margin: 0 var(--s5) var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--warn-border); border-radius: var(--radius-sm);
  background: var(--warn-weak); color: var(--warn); font-size: 13px;
  display: flex; gap: var(--s2);
}
.warning strong { font-weight: 700; }
.results { padding: var(--s2) var(--s5) var(--s5); display: grid; gap: var(--s2); }

.empty {
  padding: var(--s6) var(--s5);
  text-align: center; color: var(--ink-muted); font-size: 13px;
}

.result {
  display: grid;
  grid-template-columns: 30px 1fr minmax(160px, auto);
  align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.result--top {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent-weak) 60%, var(--bg));
}
.result__rank { font-family: var(--mono); font-size: 14px; color: var(--ink-faint); text-align: center; }
.result--top .result__rank { color: var(--accent); font-weight: 700; }
.result__std { font-family: var(--mono); font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.result__grade {
  display: inline-block; margin-top: var(--s1);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 3px;
  background: var(--accent-weak); color: var(--accent-hover);
}
.result__grade--none {
  background: var(--surface-sunken); color: var(--ink-faint);
  font-style: italic; font-weight: 500;
}
.comp {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--s3);
  margin-top: var(--s2);
}
.comp__item {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.comp__sym { font-weight: 600; color: var(--ink-faint); margin-right: 2px; }
.result__score { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); }
.result__pct { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar {
  width: 160px; height: 6px;
  background: var(--surface-sunken); border-radius: 3px; overflow: hidden;
  border: 1px solid var(--border);
}
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.foot { padding: var(--s5) 0 var(--s7); color: var(--ink-faint); font-size: 12px; }
.foot__link { color: var(--ink-muted); text-underline-offset: 3px; }
.foot__link:hover { color: var(--accent); }

/* ---------- motion ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result { animation: rise 200ms cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: var(--d, 0ms); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .result { grid-template-columns: 28px 1fr; }
  .result__score { grid-column: 2; align-items: flex-start; }
  .bar { width: 100%; max-width: 200px; }
}

/* ===================== V2 — Reverse tab ===================== */

/* ---------- tabs ---------- */
.tabs { border-bottom: 1px solid var(--border); background: var(--surface); }
.tabs__inner { display: flex; gap: var(--s5); }
.tab {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-faint); background: transparent;
  border: 0; border-bottom: 2px solid transparent;
  padding: var(--s4) 2px; margin-bottom: -1px; cursor: pointer;
  transition: color 160ms ease-out, border-color 160ms ease-out;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.tabpanel { display: grid; gap: var(--s5); }
.tabpanel[hidden] { display: none; }

/* standalone database selector (Reverse tab, outside a panel head) */
.silo-select--standalone {
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- Section A — grade lookup ---------- */
.lookup { padding: var(--s5); }
.lookup__field { display: flex; flex-direction: column; gap: var(--s2); max-width: 320px; }
.lookup__label {
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}
.lookup input {
  font-family: var(--mono); font-size: 14px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.lookup input:hover { border-color: var(--ink-faint); }
.lookup input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.lookup__result { padding: 0 var(--s5) var(--s5); }
.lookup__card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: clip; }
.lookup__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
  padding: var(--s4); background: var(--surface); border-bottom: 1px solid var(--border);
}
.lookup__std { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--ink); }
.lookup__type { margin-top: 2px; font-size: 12px; color: var(--ink-muted); }
.lookup__count {
  flex-shrink: 0; font-family: var(--mono); font-size: 11px; color: var(--accent-hover);
  background: var(--accent-weak); padding: 3px 8px; border-radius: 3px; white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) var(--s4) 0; }
.chip {
  font-size: 11px; color: var(--ink-muted); background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: 3px; padding: 2px 8px;
}

.spec { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec th {
  text-align: left; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.spec td { padding: var(--s2) var(--s4); border-bottom: 1px solid var(--surface-sunken); }
.spec tr:last-child td { border-bottom: 0; }
.spec__el { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.spec__lim, .spec__nom { font-family: var(--mono); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.spec th:nth-child(n+2), .spec td:nth-child(n+2) { text-align: right; }

/* ---------- Section B — compliance verdict ---------- */
.verdict {
  display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; padding: 2px 6px; border-radius: 3px; vertical-align: 1px;
}
.verdict--pass { color: var(--pass); background: var(--pass-weak); border: 1px solid var(--pass-border); }
.verdict--fail { color: var(--fail); background: var(--fail-weak); border: 1px solid var(--fail-border); }

.result--pass {
  border-color: var(--pass-border);
  background: color-mix(in oklch, var(--pass-weak) 88%, var(--bg));
}
.result--pass .result__rank { color: var(--pass); font-weight: 700; }

.result__meta { margin-top: var(--s2); font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

.dchips { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
.dchip {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 3px; border: 1px solid transparent; cursor: default;
}
.dchip--ok { color: var(--pass); background: var(--pass-weak); border-color: var(--pass-border); }
.dchip--bad { color: var(--fail); background: var(--fail-weak); border-color: var(--fail-border); }
.dchip--na { color: var(--ink-faint); background: var(--surface-sunken); border-color: var(--border); }

@media (max-width: 560px) {
  .tabs__inner { gap: var(--s4); }
  .lookup__head { flex-direction: column; gap: var(--s2); }
}
