/*
 * Curio - warm vintage.
 *
 * Aged paper, oxblood and brass, serif headings against a sans body. The
 * structure stays phone-first: the answer sits above the fold and the primary
 * action lives in a bottom bar inside thumb reach.
 *
 * Type is system-stacked rather than webfont-loaded. A store aisle is the worst
 * case for connectivity, and a font that arrives late is worse than one that
 * was never fancy.
 */

:root {
  color-scheme: light dark;

  --paper: #f2e9da;
  --paper-2: #e8dcc7;
  --surface: #fbf5e9;
  --ink: #2a2319;
  --ink-soft: #6f6250;
  --line: #d9c9ac;
  --rule: #c3ad88;
  --accent: #7c3a2d;        /* oxblood */
  --accent-ink: #fbf5e9;
  --brass: #8a6a2b;
  --good: #4a6b3c;
  --good-bg: #e2e8d5;
  --warn-bg: #f0e2c6;
  --bad: #8f3324;
  --bad-bg: #f2ded7;

  --radius: 4px;            /* vintage print, not app-store rounded */
  --radius-lg: 6px;
  --shadow: 0 1px 0 rgba(42, 35, 25, .05), 0 4px 14px rgba(90, 70, 40, .09);

  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17130d;
    --paper-2: #221c14;
    --surface: #201a12;
    --ink: #f0e6d3;
    --ink-soft: #a4977f;
    --line: #3b3223;
    --rule: #514530;
    --accent: #d98b6f;
    --accent-ink: #17130d;
    --brass: #cfa64f;
    --good: #93c187;
    --good-bg: #22301c;
    --warn-bg: #332914;
    --bad: #e59079;
    --bad-bg: #3a1f18;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.view { display: flex; flex-direction: column; min-height: 100dvh; }
/* display:flex outranks the [hidden] attribute's display:none, so restate it. */
.view[hidden], [hidden] { display: none !important; }

.pad { width: 100%; max-width: 600px; margin: 0 auto; padding: 14px 16px; }
.flow { display: flex; flex-direction: column; gap: 14px; }
.center-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }

.muted { color: var(--ink-soft); }
.tiny { font-size: 13.5px; line-height: 1.5; }
.center { text-align: center; }
.error { color: var(--bad); font-size: 15px; margin: 0; }

.brand {
  font-family: var(--serif);
  font-size: 23px; font-weight: 600; margin: 0;
  letter-spacing: .01em; font-variant: small-caps;
}
.brand.xl { font-size: 40px; line-height: 1.1; }

/* ------------------------------------------------------------------- bars */

.bar {
  position: sticky; z-index: 10;
  background: var(--paper);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  max-width: 600px; margin: 0 auto; width: 100%;
}
.bar.top { top: 0; padding-top: calc(8px + var(--safe-t)); border-bottom: 1px solid var(--rule); }
.bar.bottom {
  bottom: 0; margin-top: auto;
  padding-bottom: calc(10px + var(--safe-b));
  border-top: 1px solid var(--rule);
  flex-direction: column; gap: 7px;
}
.bar-title {
  flex: 1; text-align: center; font-family: var(--serif); font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-spacer { width: 74px; }
.bar.top .btn { flex: none; }
.bar .brand { flex: 1; }

/* --------------------------------------------------------------- controls */

.btn {
  font: inherit; font-weight: 600;
  border-radius: var(--radius); border: 1px solid transparent;
  padding: 12px 16px; cursor: pointer;
  background: var(--paper-2); color: var(--ink);
  min-height: 46px;
}
.btn.primary {
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--serif); font-size: 18px; letter-spacing: .02em;
  border-color: color-mix(in srgb, var(--accent) 70%, #000);
}
.btn.primary:disabled { opacity: .38; }
.btn.ghost { background: transparent; border-color: var(--rule); }
.btn.small { padding: 7px 12px; font-size: 14px; min-height: 38px; }
.btn.big { padding: 15px; font-size: 18px; min-height: 54px; }
.btn.block { width: 100%; }
.btn:active { transform: scale(.985); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.field > span:first-child { text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); }
.field .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.field input {
  font: 400 16px/1.4 var(--sans); /* 16px keeps iOS from zooming on focus */
  padding: 13px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  min-height: 50px; width: 100%;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#login-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }

/* ---------------------------------------------------------------- capture */

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 30px 16px; text-align: center;
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in srgb, var(--rule) 26%, transparent) 6px 7px) border-box;
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--rule) 45%, transparent);
  cursor: pointer; color: var(--ink);
}
.dz-icon { color: var(--accent); display: block; height: 32px; }
.dz-title { font-family: var(--serif); font-weight: 600; font-size: 20px; }
.dz-hint { font-size: 13.5px; color: var(--ink-soft); max-width: 30ch; }

.strip {
  display: flex; gap: 9px; overflow-x: auto;
  scroll-snap-type: x proximity; padding-bottom: 2px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip:empty { display: none; }
.shot {
  position: relative; flex: none; scroll-snap-align: start;
  width: 110px; aspect-ratio: 3 / 4; border-radius: var(--radius);
  overflow: hidden; background: var(--paper-2);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot button {
  position: absolute; top: 5px; right: 5px;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(24, 18, 10, .7); color: #f2e9da; font-size: 17px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
}

/* ---------------------------------------------------------------- loading */

.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.loading h2 { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 1000ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.6s; } }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips li {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
  transition: color 220ms ease, background 220ms ease, border-color 220ms ease, opacity 220ms ease;
}

/* Waiting its turn: present but clearly not yet doing anything. */
.chip.waiting { opacity: .45; }

/*
 * Currently thinking. The models genuinely run at once, so the row should look
 * like several things working in parallel - which means each chip breathes on
 * its own schedule. A synchronised pulse reads as one blinking element; out of
 * phase, it reads as a panel.
 */
.chip.working {
  opacity: 1;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--paper-2));
  animation: chip-think 1.5s ease-in-out infinite;
  will-change: opacity, transform;
}
@keyframes chip-think {
  0%, 100% {
    opacity: .5;
    transform: scale(.97);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 22%, transparent);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
  }
}

/* Offset each chip so the row shimmers rather than blinking in unison. The
   durations differ slightly too, so they never drift back into lockstep. */
.chips li:nth-child(1).working { animation-delay: 0ms;   animation-duration: 1.5s; }
.chips li:nth-child(2).working { animation-delay: 180ms; animation-duration: 1.7s; }
.chips li:nth-child(3).working { animation-delay: 360ms; animation-duration: 1.4s; }
.chips li:nth-child(4).working { animation-delay: 540ms; animation-duration: 1.8s; }
.chips li:nth-child(5).working { animation-delay: 720ms; animation-duration: 1.6s; }
.chips li:nth-child(6).working { animation-delay: 900ms; animation-duration: 1.55s; }

/* A settled chip lands rather than simply changing colour. */
.chip.answered, .chip.failed { animation: chip-settle 320ms ease-out; }
@keyframes chip-settle {
  0% { transform: scale(1.06); }
  60% { transform: scale(.98); }
  100% { transform: scale(1); }
}

.chip.answered {
  opacity: 1; color: var(--good);
  background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 40%, transparent);
}
.chip.failed {
  opacity: 1; color: var(--bad);
  background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .chip.working, .chip.answered, .chip.failed { animation: none; }
  .chip.working { opacity: 1; }
}

/* ----------------------------------------------------------------- result */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.card.tight { gap: 9px; }
.card p, .card dl { margin: 0; }
.card h2 {
  margin: 0; font-family: var(--serif); font-size: 25px; font-weight: 600;
  line-height: 1.2; letter-spacing: -.005em;
}
/* Section labels read as catalogue headings: small caps over a hairline rule. */
.card h3 {
  margin: 0 0 2px; font-family: var(--serif); font-size: 15px; font-weight: 600;
  font-variant: small-caps; letter-spacing: .09em; color: var(--ink-soft);
  border-bottom: 1px solid var(--rule); padding-bottom: 7px;
}
.subtitle { margin: 0; color: var(--ink-soft); font-family: var(--serif); font-size: 17px; font-style: italic; }

.price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-main { font-family: var(--serif); font-size: 42px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.price-range { color: var(--ink-soft); font-size: 15px; }

.badges { display: flex; flex-wrap: wrap; gap: 7px; }
.badge {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge.strong { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.badge.moderate { background: var(--warn-bg); color: var(--brass); border-color: color-mix(in srgb, var(--brass) 35%, transparent); }
.badge.weak, .badge.single, .badge.alert { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

.callout {
  border-left: 3px double var(--accent); padding: 4px 0 4px 13px; font-size: 16px;
}
.callout.bad { border-left-color: var(--bad); }
.callout strong { font-family: var(--serif); font-variant: small-caps; letter-spacing: .04em; font-size: 17px; }

.facts { display: flex; flex-direction: column; font-size: 16px; }
.fact { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px dotted var(--rule); }
.fact:last-child { border-bottom: none; padding-bottom: 0; }
.fact:first-child { padding-top: 2px; }
.fact dt {
  flex: none; width: 112px; color: var(--ink-soft);
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding-top: 3px;
}
.fact dd { margin: 0; flex: 1; min-width: 0; }

.list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 16px; }
.list.plain { list-style: none; padding-left: 0; }
.list li::marker { color: var(--brass); }

details.disclosure > summary {
  cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 17px; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 30px;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "›"; color: var(--brass); font-size: 22px; }
details.disclosure[open] > summary::after { content: "⌄"; }
details.disclosure > *:not(summary) { margin-top: 13px; }

.member { border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; font-size: 15px; background: var(--paper); }
.member + .member { margin-top: 9px; }
.member header { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 5px; }
.member strong { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.member .model { font-size: 11px; color: var(--ink-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.member.failed { opacity: .6; }

/* ---------------------------------------------------------------- history */

.history-item {
  display: flex; gap: 13px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 11px; width: 100%; text-align: left;
  cursor: pointer; font: inherit; color: inherit; min-height: 76px;
  box-shadow: var(--shadow);
}
.history-item img {
  width: 58px; height: 58px; border-radius: var(--radius); object-fit: cover;
  background: var(--paper-2); flex: none; border: 1px solid var(--rule);
}
.history-item .meta { min-width: 0; flex: 1; }
.history-item .title {
  font-family: var(--serif); font-weight: 600; font-size: 17px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item .chev { color: var(--brass); font-size: 21px; flex: none; }

/* ------------------------------------------------------------------ chat */

.flag {
  align-self: flex-start;
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent-ink); background: var(--accent);
  padding: 3px 8px; border-radius: 3px;
}

.thread { display: flex; flex-direction: column; gap: 9px; }
.turn {
  font-size: 15.5px; line-height: 1.5;
  padding: 10px 13px; border-radius: var(--radius);
  max-width: 92%;
}
.turn.owner {
  align-self: flex-end; background: var(--accent); color: var(--accent-ink);
  border-bottom-right-radius: 1px;
}
.turn.panel {
  align-self: flex-start; background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 1px;
}

.chat-form { display: flex; gap: 8px; align-items: stretch; }
.chat-input {
  flex: 1; min-width: 0;
  font: 400 16px/1.4 var(--sans); /* 16px keeps iOS from zooming on focus */
  padding: 12px 13px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  min-height: 48px;
}
.chat-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat-form .btn { flex: none; padding: 12px 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b));
  transform: translate(-50%, 10px);
  background: var(--ink); color: var(--paper);
  font: 600 14.5px var(--sans); padding: 11px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.price-unit { font-size: 15px; color: var(--ink-soft); font-weight: 600; }
.lot {
  font-size: 16px; padding: 9px 12px; border-radius: var(--radius);
  background: var(--brass-soft); border: 1px solid color-mix(in srgb, var(--brass) 38%, transparent);
}
.lot strong { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.hint { font-size: 13px; font-weight: 400; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }

/* Sold price against asking price: two different questions, side by side. */
.compare { display: flex; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.compare-half { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; background: var(--surface); min-width: 0; }
.compare-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.compare-figure { font-family: var(--serif); font-size: 18px; font-weight: 600; }

.list.plain a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Completed sales: the price carries the weight, the detail supports it. */
.sales-heading {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-soft); margin-top: 4px;
}
.list.sales { gap: 10px; margin-top: 6px; }
.sale { display: flex; flex-direction: column; gap: 2px; }
.sale-price { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.sale-meta { font-size: 14px; color: var(--ink-soft); line-height: 1.4; }

/* Setup check: one row per model, with the provider's own error when it fails. */
.btn.self { align-self: center; }
.probes { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.probe {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface);
}
.probe.ok { border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-bg); }
.probe.bad { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-bg); }
.probe.off { opacity: .72; }
.probe.off .probe-head strong { color: var(--ink-soft); }
.probe-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.probe.ok .probe-head strong { color: var(--good); }
.probe.bad .probe-head strong { color: var(--bad); }
.probe-role { font-size: 12px; color: var(--ink-soft); }
.probe-model { margin: 3px 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-soft); }
.probe-error { margin: 5px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink); }

/* Recording a purchase or a sale. */
.ledger-form { display: flex; flex-direction: column; gap: 12px; }
.ledger-form h3 { margin-top: 4px; }
.ledger-form input[type="date"] { font-family: var(--sans); }

/* Install-as-an-app prompt: a suggestion, not a demand, so it sits quietly
   below the form and disappears for good once it has been answered. */
.install {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.install-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.install-actions { display: flex; gap: 8px; margin-top: 10px; }

/* The environment listing under the setup check: names only, never values.
   Monospaced and quoted so a stray space in a name is visible rather than
   invisible, which is the whole point of showing it. */
.envbox { margin-top: 14px; }
.envhead {
  margin: 0 0 2px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.envmore { margin-top: 10px; }
.envmore > summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 6px 0;
}
.envlist { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.envrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.envrow.bad { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-bg); }
.envname {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink);
  word-break: break-all;
}
.envlen { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.envproblem { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink); }
