/* ARTRECORD — museum wall label. Dark ground so the artwork carries the color. */

:root {
  --ink: #f2efe9;
  --ink-dim: #a8a29a;
  --ink-faint: #6f6a63;
  --ground: #141312;
  --panel: #1c1b19;
  --panel-2: #23221f;
  --line: #322f2b;
  --brass: #c8a256;
  --brass-dim: #8a6f37;
  --danger: #d4705f;
  --good: #7fa66f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --radius: 4px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: env(safe-area-inset-bottom); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.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;
}

/* ---------- Chrome ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px calc(14px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(20, 19, 18, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.wordmark {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0;
  white-space: nowrap;
}
.wordmark span { color: var(--brass); }

.topbar-spacer { flex: 1; }

.count {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 120px; }

/* ---------- Controls ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--brass-dim); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a1611;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #d9b268; border-color: #d9b268; }

.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brass-dim); outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- Filter bar ---------- */

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 24px;
}
.search {
  flex: 1 1 220px;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 13px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--brass); border-color: var(--brass); color: #1a1611; font-weight: 600;
}

/* ---------- Grid ---------- */

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--brass-dim); transform: translateY(-2px); }

.card-img {
  aspect-ratio: 4 / 3;
  background: #0d0c0b center / cover no-repeat;
  border-bottom: 1px solid var(--line);
}

.card-body { padding: 13px 15px 15px; }
.card-title {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.3;
  margin: 0 0 5px;
}
.card-meta {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.card-value {
  margin-top: 9px;
  font-size: 13px;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}
.card-value.pending { color: var(--ink-faint); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-dim);
}
.empty h2 { font-family: var(--serif); font-weight: 400; margin: 0 0 8px; color: var(--ink); }

/* ---------- Add button ---------- */

.fab {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex; align-items: center; gap: 9px;
  padding: 15px 24px;
  border: none;
  border-radius: 999px;
  background: var(--brass);
  color: #1a1611;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow);
}
.fab:hover { background: #d9b268; }

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* Only an open dialog becomes a flex column — `dialog` alone would defeat
   the default display:none and reveal closed dialogs. */
dialog[open] { display: flex; flex-direction: column; }
dialog > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
dialog::backdrop { background: rgba(8, 8, 7, 0.78); }

.dialog-head {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
  font-family: var(--serif); font-size: 20px; font-weight: 400; margin: 0; flex: 1;
  line-height: 1.25; overflow-wrap: anywhere;
}
/* min-height:0 is what actually lets a flex child shrink and scroll. */
.dialog-body { flex: 1 1 auto; min-height: 0; padding: 20px; overflow-y: auto; }
.dialog-foot {
  flex: none;
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center;
  padding: 16px 20px; border-top: 1px solid var(--line);
}
.close { background: none; border: none; color: var(--ink-dim); font-size: 26px; line-height: 1; padding: 0 4px; }
.close:hover { color: var(--ink); }

/* ---------- Capture ---------- */

.capture {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-dim);
  margin-bottom: 18px;
}
.capture-preview {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: var(--radius); background: #0d0c0b; display: block; margin-bottom: 12px;
}
.capture-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Detail ---------- */

.shots { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.shot { position: relative; }
.shot img {
  width: 132px; height: 100px; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius); display: block; background: #0d0c0b;
}
.shot button {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; padding: 0;
  border: none; border-radius: 50%;
  background: rgba(8, 8, 7, 0.8); color: var(--ink); font-size: 15px; line-height: 22px;
}
.shot button:hover { background: var(--danger); color: #fff; }

.spec { display: grid; grid-template-columns: 132px 1fr; gap: 6px 16px; margin: 0 0 22px; font-size: 14px; }
.spec dt { color: var(--ink-faint); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; padding-top: 3px; }
.spec dd { margin: 0; overflow-wrap: anywhere; }

.section-label {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-dim); margin: 26px 0 12px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line);
}

/* ---------- AI insight ---------- */

.insight-headline { font-family: var(--serif); font-size: 19px; line-height: 1.4; margin: 0 0 12px; }
.insight p { margin: 0 0 14px; }

.valuation {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 18px 0;
}
.valuation-range {
  font-family: var(--serif);
  font-size: 27px;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.valuation-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.valuation-note { font-size: 13px; color: var(--ink-dim); margin-top: 10px; }

.confidence {
  display: inline-block; margin-left: 10px; padding: 2px 9px;
  border-radius: 999px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  vertical-align: middle;
}
.confidence.low { background: rgba(212, 112, 95, 0.16); color: var(--danger); }
.confidence.medium { background: rgba(200, 162, 86, 0.16); color: var(--brass); }
.confidence.high { background: rgba(127, 166, 111, 0.16); color: var(--good); }

.disclaimer {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 12px;
}

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.lists h4 { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); margin: 14px 0 7px; font-weight: 500; }
.lists ul { margin: 0; padding-left: 19px; font-size: 14px; }
.lists li { margin-bottom: 5px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; color: var(--ink-dim); }

/* ---------- Feedback ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius); padding: 12px 18px;
  box-shadow: var(--shadow); max-width: min(440px, calc(100vw - 32px)); font-size: 14px;
}
.toast.error { border-left-color: var(--danger); }

.working { display: flex; align-items: center; gap: 11px; color: var(--ink-dim); font-size: 14px; }
.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid var(--line); border-top-color: var(--brass); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .card:hover { transform: none; }
}

.gate { max-width: 340px; margin: 18vh auto; padding: 0 20px; text-align: center; }
.gate h1 { font-family: var(--serif); font-weight: 400; letter-spacing: 0.14em; text-transform: uppercase; font-size: 20px; }
.gate .field { text-align: left; }

@media (max-width: 620px) {
  .wrap { padding: 18px 14px 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .lists, .field-row { grid-template-columns: 1fr; }
  .spec { grid-template-columns: 1fr; gap: 2px; }
  .spec dd { margin-bottom: 12px; }
  .fab { right: 14px; left: 14px; justify-content: center; }
  .valuation-range { font-size: 23px; }
}

/* ---------- Connection status ---------- */

.netpill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 4px 12px 4px 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.netpill::before {
  content: "";
  width: 7px; height: 7px; flex: none;
  border-radius: 50%;
  background: var(--good);
}
.netpill.is-off { color: var(--danger); border-color: rgba(212, 112, 95, 0.4); }
.netpill.is-off::before { background: var(--danger); }
.netpill.is-waiting { color: var(--brass); border-color: var(--brass-dim); }
.netpill.is-waiting::before { background: var(--brass); }

/* ---------- Held on this device ---------- */

.card-pending { border-color: var(--brass-dim); }
.card-pending .card-img { opacity: 0.72; }
.card-value.waiting { color: var(--brass); }
.card-value.stuck { color: var(--danger); }

.banner {
  border: 1px solid var(--brass-dim);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: rgba(200, 162, 86, 0.08);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}
.banner strong { color: var(--brass); font-weight: 600; }
.banner-bad { border-color: var(--danger); background: rgba(212, 112, 95, 0.08); }
.banner-bad strong { color: var(--danger); }

/* ---------- Tablet ---------- */

@media (min-width: 768px) and (max-width: 1180px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
  .wrap { padding: 22px 22px 130px; }
}

/* Touch targets on phones and tablets: the FAB and the pill are used one-handed
   while holding a painting, so keep them comfortably large. */
@media (pointer: coarse) {
  .btn { padding: 11px 18px; }
  .btn-sm { padding: 8px 13px; }
  .netpill { padding: 7px 14px 7px 12px; font-size: 13px; }
  .chip { padding: 8px 14px; }
}

/* The top bar carries four things and a phone is 375px wide. The connection pill
   is the one that matters in the field, so it never shrinks; the wordmark gives
   up space first and the export label loses its verb. */
@media (max-width: 620px) {
  .topbar { gap: 9px; padding-left: 14px; padding-right: 14px; }
  .wordmark { font-size: 15px; letter-spacing: 0.08em; min-width: 0; overflow: hidden; }
  .count { display: none; }
  .csv-long { display: none; }
  .csv-link { flex: none; white-space: nowrap; }
  .netpill { flex: none; padding: 6px 11px 6px 9px; font-size: 12px; }
}

/* ---------- Cloud edition ---------- */

.setup { max-width: 460px; text-align: left; }
.setup h1 { text-align: center; }
.setup-steps {
  margin: 18px 0;
  padding-left: 22px;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.6;
}
.setup-steps li { margin-bottom: 10px; }
.setup-steps code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 12.5px;
}
.setup-steps strong { color: var(--ink); font-weight: 600; }

.account-line {
  margin: 44px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-faint);
}
.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-dim);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: var(--ink); }
