:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e2ded5;
  --field: #faf9f6;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe5;
  --good: #2e7d4f;
  --mid: #b07a12;
  --bad: #b3362b;
  --warn: #a8641a;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  --r: 14px;
  --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --card: #1f2226;
    --ink: #e9e7e2;
    --muted: #9a9ea5;
    --line: #33373d;
    --field: #262a2f;
    --accent: #6cbfa6;
    --accent-ink: #0f1a17;
    --accent-soft: #24433a;
    --good: #6cc48f;
    --mid: #e0b04f;
    --bad: #ef7b6f;
    --warn: #e3a35a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h2 { font-size: 1.05rem; margin: 0 0 12px; letter-spacing: .01em; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.warn { color: var(--warn); }
.bad { color: var(--bad); font-weight: 600; }
.good { color: var(--good); font-weight: 600; }
.cards > .empty { grid-column: 1 / -1; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- controls ---------- */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { min-height: 0; padding: 0 4px; border: 0; background: none; color: var(--accent); text-decoration: underline; font-size: inherit; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; line-height: 1.45; }
select { -webkit-appearance: none; appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------- top bar (the sidebar, tab bar and account menu: nav.css) ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.pill { font-size: .85rem; padding: 6px 12px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line); }
.pill.ok { color: var(--good); }
.pill.busy { color: var(--muted); }
.pill.off { color: #fff; background: var(--bad); border-color: var(--bad); }

main { max-width: 1200px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)); }
.banner { background: var(--card); border: 1px solid var(--bad); color: var(--bad); padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }

/* ---------- conflict banner (#12), history (#21) ---------- */
#conflicts { max-width: 1200px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-left)); }
#conflicts:not(:empty) { padding-top: 16px; }
.banner.cf { border-color: var(--warn); color: var(--ink); align-items: start; flex-wrap: wrap; margin-bottom: 0; }
.banner.cf + .banner.cf { margin-top: 8px; }
.cf-msg { flex: 1 1 320px; min-width: 0; }
.cf-msg b { color: var(--warn); }
.cf-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.cf-t, .hist-t { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .9rem; }
.cf-t th, .cf-t td, .hist-t th, .hist-t td { text-align: left; vertical-align: top; padding: 6px 8px; border-top: 1px solid var(--line); }
.cf-v, .hist-v { white-space: pre-wrap; word-break: break-word; }
.hist-v { display: block; max-height: 12em; overflow: auto; font-size: .85rem; }
.c-body .hist { list-style: none; margin: 0; padding: 0; display: block; }
.hist > li { border-top: 1px solid var(--line); padding: 8px 0; }
.hist .hl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hist .hl > span { flex: 1 1 200px; }

/* ---------- list ---------- */
/* search box (#49): our own ✕ (iPad Safari shows none), so hide the native one */
.lsearch { position: relative; margin-bottom: 12px; }
.lsearch input { padding-right: var(--tap); font-size: 1rem; }
.lsearch input::-webkit-search-cancel-button { -webkit-appearance: none; }
.lsearch .x { position: absolute; right: 0; top: 0; height: 100%; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.toolbar label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); min-width: 160px; flex: 1; }
.toolbar select { color: var(--ink); font-size: 1rem; }
.toolbar.ignored label:not(:nth-last-of-type(1)) { opacity: .45; }  /* searching: only Sort still applies */
.toolbar .primary { flex: 0 0 auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); }
a.card { display: flex; flex-direction: column; text-decoration: none; color: inherit; overflow: hidden; }
a.card:active { transform: scale(.99); }
a.card.prio-high { border-color: var(--accent); }
a.card.discarded { opacity: .55; }
.cover { position: relative; aspect-ratio: 16 / 9; background: var(--field); display: grid; place-items: center; font-size: 2.4rem; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .chip { position: absolute; left: 10px; top: 10px; }
.chip { font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.st-favorite { background: #f6d55c; color: #3a2f00; }
.st-visit_scheduled { background: var(--accent); color: var(--accent-ink); }
.st-visited { background: var(--accent-soft); }
.st-discarded { background: var(--muted); color: var(--bg); }
.cover .chip.sugg { left: auto; right: 10px; }  /* ✨ Suggested by Claude (#18) */
/* Priority on list cards (#28): ⭐ High in accent, Low muted, nothing for normal. */
.tag-prio { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag-prio.hi { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tag-new { font-size: .75rem; font-weight: 700; color: var(--accent); white-space: nowrap; }  /* never opened (#76) */
.body { padding: 12px 14px 14px; display: grid; gap: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.money { font-size: .95rem; }
.money sup { color: var(--warn); font-weight: 700; }
/* Scam flags (#65) on cards and Info: the reason in words, not just the ⚠️ icon (no hover on the iPad). */
.fraud { list-style: none; margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--bad); border-radius: 4px; font-size: .85rem; color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent); }
.fraud li + li { margin-top: 2px; }
.flags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.flag { font-size: 1rem; min-width: 1.4em; text-align: center; }
/* ✓ Visited (#52): list cards and the Info header */
.tag-visited { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--good); color: var(--card); white-space: nowrap; }
.tag-pending { background: var(--warn); }
.visit { font-size: .88rem; color: var(--accent); font-weight: 600; }
.score { flex: 0 0 auto; min-width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; background: var(--field); color: var(--muted); }
.score.hi { background: var(--good); color: #fff; }
.score.mid { background: var(--mid); color: #fff; }
.score.lo { background: var(--bad); color: #fff; }

/* ---------- detail ---------- */
.detail { max-width: 920px; margin: 0 auto; display: grid; gap: 16px; }
.back { text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
section.card { padding: 16px; }
.hero { width: calc(100% + 32px); margin: -16px -16px 12px; max-height: 320px; object-fit: cover; border-radius: var(--r) var(--r) 0 0; display: block; }
input.title { font-size: 1.5rem; font-weight: 700; border-color: transparent; background: transparent; padding-left: 4px; }
input.title:focus { background: var(--field); }
.headline { justify-content: flex-start; flex-wrap: wrap; margin: 8px 0 12px; }
.why { background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; }
.links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.links a { display: inline-flex; align-items: center; min-height: var(--tap); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.f { display: grid; gap: 4px; align-content: start; margin: 0; }
.f > span { font-size: .8rem; color: var(--muted); }
.f.wide { grid-column: 1 / -1; }
.summary { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
/* Rent projection "?" (#63, ui.js projHTML): a tap-to-open note after the line */
.proj-q { display: inline; }
.proj-q summary { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 50%; cursor: pointer; list-style: none; color: var(--muted); font-weight: 600; vertical-align: middle; }
.proj-q summary::-webkit-details-marker { display: none; }
.proj-q[open] p { margin: 6px 0 0; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); }
.seg button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 0 10px; min-width: var(--tap); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ratings */
.rate { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rb { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rb button { min-height: 58px; padding: 4px; display: grid; align-content: center; justify-items: center; gap: 2px; line-height: 1.15; }
.rb button b { font-size: 1.15rem; }
.rb button small { font-size: .68rem; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.rb button.auto { border: 2px dashed var(--accent); }
.rb button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rb button.on small { color: inherit; opacity: .85; }
.breakdown { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.breakdown th, .breakdown td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.breakdown th:not(:first-child), .breakdown td:not(:first-child) { text-align: right; width: 64px; }
.breakdown tfoot td { border: 0; font-weight: 600; padding-top: 10px; }
.breakdown tfoot td:last-child { font-size: 1.3rem; }

/* lists */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.items, .qs { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.items li, .qs li { display: flex; gap: 6px; align-items: center; }
button.x { flex: 0 0 var(--tap); padding: 0; color: var(--muted); background: transparent; border-color: transparent; }
.quick { display: flex; gap: 6px; }
.quick button { flex: 0 0 auto; }
.qs li { align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.qs .qa { flex: 1; display: grid; gap: 4px; }
.qs .q { border-color: transparent; background: transparent; padding-left: 2px; font-weight: 500; }
.qs .q:focus { background: var(--field); }
.qs li.done .q { color: var(--muted); text-decoration: line-through; }
.qs .seg { max-width: 320px; }
button.q-kind { flex: 0 0 auto; padding: 0 8px; font-size: .8rem; color: var(--muted); }
button.q-kind.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chk { flex: 0 0 var(--tap); height: var(--tap); display: grid; place-items: center; cursor: pointer; }
.chk input { width: 24px; height: 24px; min-height: 0; accent-color: var(--accent); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; display: block; }
.photos figure { display: grid; gap: 6px; align-content: start; }
.photos figure.is-cover img { outline: 3px solid var(--accent); outline-offset: -3px; }
.photos figure.up img { opacity: .6; }
.photos figure.err img { opacity: .35; }
.photos input { min-height: 36px; padding: 4px 8px; font-size: .9rem; }
.ph-acts { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ph-acts button:not(.x) { min-height: 36px; padding: 0 10px; font-size: .85rem; }
.ph-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ph-bar + .quick { margin-bottom: 14px; }
label.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center;
  border: 1px solid var(--line); background: var(--card); position: relative; -webkit-tap-highlight-color: transparent;
}
label.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
/* visually hidden but still clickable through its label (iOS ignores display:none file inputs in some versions) */
.vh { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; overflow: hidden; pointer-events: none; }
button:disabled { opacity: .5; cursor: default; }

.danger { display: flex; align-items: center; gap: 12px; padding: 8px 0 32px; }
.danger button { color: var(--bad); border-color: var(--bad); background: transparent; }

/* dialog */
dialog { border: 0; border-radius: var(--r); padding: 20px; width: min(480px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / .25); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { display: grid; gap: 14px; }
dialog h2 { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

/* portrait iPad / phones */
@media (max-width: 700px) {
  .rate { grid-template-columns: 1fr; gap: 6px; }
  .two { grid-template-columns: 1fr; }
}

/* login page */
body.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#login { width: min(400px, 100%); padding: 24px; display: grid; gap: 14px; }
#login h1 { font-size: 1.4rem; margin: 0 0 4px; text-align: center; }
#login .remember { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
#login .remember input { width: 24px; height: 24px; min-height: 0; flex: 0 0 auto; accent-color: var(--accent); }
#login p { margin: 0; }
