/* Scout -- mobile first, dark by default.

   This is a tool used one-handed, outdoors, standing over a box of stuff. So:
   big tap targets, high contrast, no hover-dependent affordances, and nothing
   that reflows when an image finally loads. */

:root {
  --bg:        #0b1020;
  --bg-raise:  #131a30;
  --bg-sunk:   #080c19;
  --line:      #232c47;
  --text:      #e8ecf6;
  --text-dim:  #94a0bd;
  --accent:    #5eead4;
  --accent-dk: #0f766e;
  --warn:      #fbbf24;
  --bad:       #f87171;
  --good:      #4ade80;
  --radius:    14px;
  --pad:       16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:       #f6f7fb;
    --bg-raise: #ffffff;
    --bg-sunk:  #eceff7;
    --line:     #d6dbe8;
    --text:     #131a30;
    --text-dim: #5b6683;
    --accent:   #0d9488;
    --accent-dk:#0f766e;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; color: inherit; }

/* --- top bar ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
  padding: max(6px, env(safe-area-inset-top)) 8px 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  text-align: center;
  /* A long item name must not push the buttons off the edge. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__back, .topbar__menu {
  height: 40px;
  width: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

/* The back button is toggled with the `hidden` attribute, whose UA rule is
   display:none — which removes it from the grid and drops the title into the
   44px column, truncating it to "Sco…". Keep the cell, hide the ink. */
.topbar__back[hidden] {
  display: block;
  visibility: hidden;
}
.topbar__back:active, .topbar__menu:active { background: var(--bg-raise); }
.topbar__menu { font-size: 18px; }

.view {
  padding: var(--pad);
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
}

/* --- buttons ------------------------------------------------------------ */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-raise);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #04211d;
}
@media (prefers-color-scheme: light) { .btn--primary { color: #fff; } }

.btn--block { display: block; width: 100%; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* --- the big capture affordance ---------------------------------------- */

.capture-cta {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.capture-cta__main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 96px;
  font-size: 18px;
  border-radius: 18px;
}
.capture-cta__main .ico { font-size: 26px; }

/* --- cards / list ------------------------------------------------------- */

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 12px;
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.card__title { margin: 0; font-size: 16px; font-weight: 650; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 26px 0 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  color: inherit;
}
.item-row:active { background: var(--bg-sunk); }

.item-row__thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-sunk);
  display: block;
}
.item-row__body { min-width: 0; }
.item-row__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-row__sub {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-row__value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- status pills ------------------------------------------------------- */

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill[data-status="identifying"],
.pill[data-status="researching"] {
  background: color-mix(in srgb, var(--accent) 20%, var(--bg-sunk));
  color: var(--accent);
}
.pill[data-status="questions"] {
  background: color-mix(in srgb, var(--warn) 20%, var(--bg-sunk));
  color: var(--warn);
}
.pill[data-status="done"] {
  background: color-mix(in srgb, var(--good) 18%, var(--bg-sunk));
  color: var(--good);
}
.pill[data-status="error"] {
  background: color-mix(in srgb, var(--bad) 18%, var(--bg-sunk));
  color: var(--bad);
}

/* --- photo grid --------------------------------------------------------- */

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.photos__cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
}
.photos__cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos__drop {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

/* --- fields ------------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field__why {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: -2px;
  margin-bottom: 6px;
  font-weight: 400;
}
.field input, .field textarea, .field select {
  width: 100%;
  min-width: 0;          /* grid/flex children refuse to shrink without this */
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 48px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  min-height: 42px;
}
.choice[aria-pressed="true"] {
  background: var(--accent);
  border-color: transparent;
  color: #04211d;
  font-weight: 650;
}

/* --- the report --------------------------------------------------------- */

.prices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 14px;
}
.price {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}
.price--market { border-color: var(--accent); }
.price__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 700;
}
.price__value {
  font-size: 22px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.price--market .price__value { color: var(--accent); }

.comp {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.comp:last-child { border-bottom: 0; }
.comp__title { font-size: 14px; }
.comp__meta { font-size: 12px; color: var(--text-dim); }
.comp__price { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.comp__tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.comp__tag[data-sold="true"] { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.comp__tag[data-sold="false"] { background: color-mix(in srgb, var(--text-dim) 20%, transparent); color: var(--text-dim); }

.platform {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.platform:last-child { border-bottom: 0; }
.platform__name { font-weight: 650; }
.platform__why { font-size: 13px; color: var(--text-dim); }
.platform__price { font-weight: 700; font-variant-numeric: tabular-nums; }

ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin-bottom: 7px; }

.copybox {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}

.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
}

/* --- waiting state ------------------------------------------------------ */

.working {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.spinner {
  width: 20px;
  height: 20px;
  flex: none;
  border: 2.5px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* --- live progress feed ------------------------------------------------- */

.feed {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
  /* Anchor to the bottom so new lines push up like a terminal rather than
     making the reader chase them. */
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.feed:empty { display: none; }

.feed__line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  color: var(--text-dim);
}
.feed__line[data-kind="tool"] { color: var(--text); }
.feed__time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  opacity: .65;
  padding-top: 1px;
}

/* A small pulsing dot marks a row that is actively working. */
.dot-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot-pulse { animation: none; } }

.item-row__sub--live { color: var(--accent); }

/* --- toggle ------------------------------------------------------------- */

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  cursor: pointer;
  min-height: 56px;
}
.toggle__box {
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  position: relative;
  transition: background .15s ease;
}
.toggle__box::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .15s ease, background .15s ease;
}
.toggle[aria-pressed="true"] .toggle__box {
  background: var(--accent);
  border-color: transparent;
}
.toggle[aria-pressed="true"] .toggle__box::after {
  transform: translateX(18px);
  background: #04211d;
}
.toggle__label { display: block; font-weight: 600; }
.toggle__note { display: block; font-size: 12px; color: var(--text-dim); }

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid;
}
.banner--warn {
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-raise));
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}
.banner--bad {
  background: color-mix(in srgb, var(--bad) 12%, var(--bg-raise));
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  z-index: 60;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  max-width: calc(100vw - 32px);
}

/* --- lightbox ----------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 12px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* --- login -------------------------------------------------------------- */

.login-body { display: grid; place-items: center; min-height: 100dvh; }
.login { width: min(380px, calc(100vw - 40px)); text-align: center; padding: 20px; }
.login__mark { font-size: 46px; color: var(--accent); line-height: 1; }
.login__title { margin: 10px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.login__sub { margin: 0 0 26px; color: var(--text-dim); font-size: 14px; }
.login__form { text-align: left; }
.login__error {
  color: var(--bad);
  font-size: 14px;
  margin: 12px 0 0;
  text-align: center;
}
