/* ---------------------------------------------------------------------
   Token system
   Color:  #1B1E23 gunmetal (bg), #262B33 panel, #B8863B brass (accent),
           #C97A4A copper (secondary accent), #ECE7DC bone (text),
           #8B93A0 steel (muted text/borders)
   Type:   Oswald (display / stamped-plate headers), IBM Plex Sans (body),
           IBM Plex Mono (all figures & data — caliper-readout feel)
   Layout: workbench grid of labeled search "tool cards" + a torn ticket
           stub for the cost output.
   Signature: the plate header (stamped metal tag) + perforated ticket stub.
   ------------------------------------------------------------------- */

:root {
  --gunmetal: #1B1E23;
  --panel: #242932;
  --panel-raised: #2C323C;
  --brass: #B8863B;
  --brass-bright: #D8A94F;
  --copper: #C97A4A;
  --bone: #ECE7DC;
  --steel: #8B93A0;
  --steel-dim: #565E6B;
  --danger: #C15B4A;
  --radius: 3px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--gunmetal);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(184,134,59,0.06), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(201,122,74,0.05), transparent 40%);
  color: var(--bone);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  min-height: 100vh;
}

@media (prefers-reduced-motion: no-preference) {
  .card, .ticket, .suggest__item { transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease; }
}

/* ---------------------------------------------------------------- plate */
.plate {
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  border-bottom: 1px solid #33394420;
}
.plate__stamp {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brass-bright);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.plate__sub {
  margin-top: 0.4rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--steel);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- bench */
.bench {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid #34394330;
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.3rem;
  position: relative;
}
.card--load { margin-bottom: 1rem; background: var(--panel-raised); border-color: var(--brass); border-width: 1px; }
.card--batch { margin-top: 1rem; max-width: 260px; }

.card__label {
  margin: 0 0 0.7rem;
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--bone);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--gunmetal);
  background: var(--brass);
  border-radius: 2px;
  padding: 0.1rem 0.35rem;
}
.optional { font-family: 'IBM Plex Sans', sans-serif; text-transform: none; font-weight: 400; font-size: 0.75rem; color: var(--steel); letter-spacing: 0; }

.hint {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--steel);
  line-height: 1.4;
}

/* ---------------------------------------------------------- search field */
.search-field { position: relative; }

.search-field input[type="text"] {
  width: 100%;
  background: var(--gunmetal);
  border: 1px solid #3A414D;
  border-radius: var(--radius);
  color: var(--bone);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  outline: none;
}
.search-field input[type="text"]:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(184,134,59,0.15);
}
.search-field input[type="text"]::placeholder { color: var(--steel-dim); }

.search-field.has-selection input[type="text"] {
  border-color: var(--copper);
  color: var(--brass-bright);
  font-weight: 500;
}

.suggest {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel-raised);
  border: 1px solid #3A414D;
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}

.suggest__item {
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #33394330;
  font-size: 0.88rem;
}
.suggest__item:last-child { border-bottom: none; }
.suggest__item:hover, .suggest__item.active { background: rgba(184,134,59,0.14); }
.suggest__item-title { color: var(--bone); font-weight: 500; }
.suggest__item-meta {
  display: block;
  margin-top: 0.15rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  color: var(--steel);
}
.suggest__empty { padding: 0.65rem 0.75rem; font-size: 0.82rem; color: var(--steel); }

.source-link {
  display: inline-block;
  margin-left: 0.4rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--steel);
  text-decoration: none;
  border-bottom: 1px dotted var(--steel-dim);
  white-space: nowrap;
}
.source-link:hover { color: var(--brass-bright); border-bottom-color: var(--brass-bright); }

/* ------------------------------------------------------------- subfield */
.subfield {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--steel);
}
.subfield--inline { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0; }
.subfield input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  background: var(--gunmetal);
  border: 1px solid #3A414D;
  border-radius: var(--radius);
  color: var(--bone);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
  padding: 0.55rem 0.65rem;
  outline: none;
}
.subfield--inline input[type="number"] { width: 90px; margin-top: 0; text-align: right; }
.subfield input[type="number"]:focus { border-color: var(--brass); }

/* ---------------------------------------------------------------- ticket */
.ticket {
  margin-top: 2rem;
  background: var(--panel);
  border: 1px solid #34394330;
  border-radius: var(--radius);
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
}
.ticket__head {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 0.9fr;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--steel);
  border-bottom: 1px dashed #3A414D;
  text-transform: uppercase;
}
.ticket__row {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 0.9fr;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #2A2F38;
  align-items: baseline;
}
.ticket__row:last-child { border-bottom: none; }
.ticket__row-label { color: var(--brass-bright); font-family: 'IBM Plex Sans', sans-serif; font-weight: 500; }
.ticket__row-detail { color: var(--steel); font-size: 0.78rem; }
.ticket__row-cost { text-align: right; color: var(--bone); }

.ticket__perf {
  height: 0;
  border-top: 1px dashed var(--steel-dim);
  position: relative;
}
.ticket__perf::before, .ticket__perf::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gunmetal);
}
.ticket__perf::before { left: -6px; }
.ticket__perf::after { right: -6px; }

.ticket__total { padding: 1rem 1.1rem 1.2rem; }
.ticket__total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.3rem 0;
}
.ticket__total-row span:first-child {
  font-family: 'IBM Plex Sans', sans-serif;
  color: var(--steel);
  font-size: 0.85rem;
}
.figure { font-size: 1.1rem; color: var(--bone); }
.figure--lg { font-size: 1.9rem; color: var(--brass-bright); font-weight: 600; }
.ticket__total-row--batch { margin-top: 0.2rem; padding-top: 0.6rem; border-top: 1px solid #2A2F38; }

.empty-state {
  margin-top: 2rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--steel);
  font-size: 0.88rem;
  border: 1px dashed #3A414D;
  border-radius: var(--radius);
}

.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.74rem;
  color: var(--steel-dim);
}

/* -------------------------------------------------------------- mobile */
@media (max-width: 560px) {
  .ticket__head, .ticket__row { grid-template-columns: 1fr; gap: 0.15rem; }
  .ticket__row-cost { text-align: left; }
  .ticket__head span:not(:first-child) { display: none; }
}

/* --------------------------------------------------------- focus/a11y */
a:focus-visible, input:focus-visible, .suggest__item:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}
