/* Rent Radar — warm, photo-forward house hunting.
   The photograph is the most persuasive thing on the page, so it leads each
   card; everything else is quiet around it. Sage is the accent, EPC keeps its
   own scale because there the colour carries meaning. */

:root {
  color-scheme: light dark;

  --paper:      #faf6f2;
  --paper-deep: #f3ece6;
  --surface:    #ffffff;
  --ink:        #2b2028;
  --ink-soft:   #6e6169;
  --ink-faint:  #9a8e94;
  --line:       #e8ded6;
  --line-firm:  #d8c9be;

  --sage:       #5f7f6b;
  --sage-deep:  #4a6654;
  --sage-wash:  #e9f0eb;
  --rose:       #b5717f;
  --rose-wash:  #fbeef0;
  --gold:       #a97f36;
  --gold-wash:  #f9f0dd;

  --shadow-soft: 0 1px 2px rgba(74, 54, 62, .04), 0 10px 28px rgba(74, 54, 62, .07);
  --shadow-lift: 0 2px 6px rgba(74, 54, 62, .07), 0 18px 40px rgba(74, 54, 62, .11);

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Karla', ui-sans-serif, system-ui, 'Segoe UI', sans-serif;

  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #1a1518;
    --paper-deep: #221b1f;
    --surface:    #241d21;
    --ink:        #f2e9ec;
    --ink-soft:   #b9a9b0;
    --ink-faint:  #8b7b83;
    --line:       #352b30;
    --line-firm:  #46383e;

    --sage:       #9dc4ab;
    --sage-deep:  #b6d6c1;
    --sage-wash:  #22322a;
    --rose:       #e0a3ae;
    --rose-wash:  #3a252b;
    --gold:       #dfb972;
    --gold-wash:  #362a17;

    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14.5px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- masthead ---------------- */

.masthead {
  background: linear-gradient(180deg, var(--paper-deep), var(--paper));
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 40px 32px 30px;
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: clamp(34px, 5vw, 46px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brief {
  margin: 12px 0 0;
  max-width: 60ch;
  font-size: 15px;
  color: var(--ink-soft);
}

.brief b { color: var(--ink); font-weight: 600; }

.destinations { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.dest {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.dest b { font-size: 13.5px; font-weight: 600; }
.dest span { font-size: 12.5px; color: var(--ink-faint); }

/* ---------------- toolbar ---------------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.toolbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.toolbar-inner.chips { padding-top: 0; padding-bottom: 14px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field.search { flex: 1 1 280px; min-width: 210px; }

.field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
}

input[type="search"], input[type="number"], select {
  font: 400 14px var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-firm);
  border-radius: 999px;
  padding: 9px 15px;
  min-width: 96px;
}

input[type="search"] { width: 100%; }
select { min-width: 132px; cursor: pointer; }

input::placeholder { color: var(--ink-faint); }

input:focus-visible, select:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.dirbtn {
  font: 500 13.5px var(--sans);
  padding: 9px 16px;
  border: 1px solid var(--line-firm);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.dirbtn:hover { color: var(--ink); border-color: var(--sage); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border: 1px solid var(--line-firm);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.chip:has(input:checked) {
  background: var(--sage-wash);
  border-color: var(--sage);
  color: var(--sage-deep);
  font-weight: 600;
}

.chip input { margin: 0; accent-color: var(--sage); }

.reset {
  font: 400 13.5px var(--sans);
  padding: 7px 14px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reset:hover { color: var(--ink); }

.tally { margin-left: auto; font-size: 13.5px; color: var(--ink-soft); }
.tally b { color: var(--ink); font-weight: 600; }

/* ---------------- card grid ---------------- */

main { max-width: 1360px; margin: 0 auto; padding: 28px 32px 64px; }

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

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .25s ease, border-color .25s ease;
}

.card:hover { box-shadow: var(--shadow-lift); border-color: var(--line-firm); }
.card.applied { border-color: var(--sage); }
.card.option { border-color: var(--gold); }

/* photo */
.photo {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--paper-deep);
}

.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo.none {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 34px;
  color: var(--ink-faint);
}

.badges {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.14);
}

.badge.new    { color: var(--sage-deep); background: var(--sage-wash); }
.badge.option { color: var(--gold);      background: var(--gold-wash); }
.badge.gone   { color: var(--ink-soft);  background: var(--paper-deep); }

.epc {
  position: absolute;
  right: 12px; bottom: 12px;
  min-width: 40px;
  text-align: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 5px rgba(0,0,0,.2);
}

.epc-a { background: #3f9e63; color: #fff; }
.epc-b { background: #8dbf50; color: #17240f; }
.epc-c { background: #e0c944; color: #241f08; }
.epc-d { background: #eda449; color: #2b1a06; }
.epc-e { background: #e5813c; color: #fff; }
.epc-f { background: #d4553a; color: #fff; }
.epc-g { background: #b23a37; color: #fff; }
.epc-na { background: var(--surface); color: var(--ink-faint); font-weight: 500; }

/* body */
.body { padding: 18px 18px 0; flex: 1; }

.priceline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.price {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
}

.costs { font-size: 12.5px; color: var(--ink-faint); }

.title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  text-decoration: none;
}

.title:hover { color: var(--sage-deep); text-decoration: underline; text-underline-offset: 2px; }

.addr { margin-top: 3px; font-size: 13px; color: var(--ink-soft); }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.fact {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* the two commutes — the reason this tool exists, so they get real space */
.commutes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 16px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.commute { background: var(--surface); padding: 10px 12px; }
.commute-to { font-size: 11.5px; color: var(--ink-faint); }
.commute-time { font-family: var(--display); font-size: 18px; font-weight: 500; margin-top: 1px; }
.commute-km { font-size: 12px; color: var(--ink-soft); }
.commute.missing .commute-time { font-size: 14px; color: var(--ink-faint); font-family: var(--sans); }

/* footer of a card */
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.applybox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

.applybox input { width: 16px; height: 16px; accent-color: var(--sage); cursor: pointer; }
.applybox:has(input:checked) { color: var(--sage-deep); font-weight: 600; }

.note {
  flex: 1;
  min-width: 0;
  font: 400 13px var(--sans);
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  resize: none;
  height: 32px;
}

.note::placeholder { color: var(--ink-faint); }
.note:hover { border-color: var(--line-firm); }
.note:focus { border-color: var(--sage); outline: none; }
.note.saved { border-color: var(--sage); background: var(--sage-wash); }

.src { font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }

/* ---------------- empty + footer ---------------- */

.empty {
  margin: 40px auto;
  max-width: 44ch;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
}

footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 32px 48px;
  color: var(--ink-faint);
  font-size: 12.5px;
}

footer h2 { margin: 0 0 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
footer table { border-collapse: collapse; }
footer td { padding: 2px 18px 2px 0; white-space: nowrap; }
footer .bad { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 700px) {
  .masthead-inner, .toolbar-inner, main, footer { padding-left: 18px; padding-right: 18px; }
  .masthead-inner { padding-top: 26px; padding-bottom: 18px; }
  .grid { grid-template-columns: 1fr; }

  /* On a phone the filter bar needs four or five rows, and pinned to the top it
     covered most of the screen. Here it scrolls away with the page instead. */
  .toolbar {
    position: static;
    backdrop-filter: none;
    background: var(--surface);
  }

  /* Two controls to a row rather than eight strung across one. */
  .field { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .field.search { flex: 1 1 100%; }
  .dirbtn { flex: 1 1 calc(50% - 8px); }
  select, input[type="number"] { width: 100%; min-width: 0; }

  .toolbar-inner.chips { gap: 8px; }
  .tally { flex: 1 1 100%; margin-left: 0; }

  .destinations { gap: 8px; }
  .tabs { position: sticky; top: 0; z-index: 15; background: var(--paper); }
}

/* ---------------- sign in ---------------- */

.signin-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--paper-deep), var(--paper));
}

.signin {
  width: min(92vw, 400px);
  padding: 40px 36px 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  text-align: left;
}

.signin h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}

.signin > p {
  margin: 10px 0 26px;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.signin label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.signin input {
  width: 100%;
  font: 400 15px var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-firm);
  border-radius: 999px;
  padding: 11px 17px;
}

.signin button {
  width: 100%;
  margin-top: 14px;
  font: 600 15px var(--sans);
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--sage);
  color: #fff;
  cursor: pointer;
}

.signin button:hover { background: var(--sage-deep); }
.signin button:disabled { opacity: .6; cursor: progress; }

.signin .problem {
  margin: 14px 0 0;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--rose-wash);
  color: var(--rose);
  font-size: 13.5px;
}

/* ---------------- tabs ---------------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 13px;
  margin-right: 22px;
  border: 0;
  background: none;
  font: 600 15px var(--sans);
  color: var(--ink-faint);
  cursor: pointer;
}

.tab:hover { color: var(--ink-soft); }

.tab.is-active { color: var(--ink); }

/* Sits on the container's border rather than adding height, so switching tabs
   never shifts the grid below. */
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--sage);
}

.tabcount {
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
}

.tab.is-active .tabcount { background: var(--sage-wash); color: var(--sage-deep); }

/* ---------------- application follow-up ---------------- */

/* Only meaningful inside the Applied tab, so the chips hide elsewhere.
   Set by renderTabs() on <body>. */
.chip.appliedonly { display: none; }
body.tab-applied .chip.appliedonly { display: inline-flex; }

.followup {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.card.replied .followup {
  border-color: var(--sage);
  background: var(--sage-wash);
}

.followup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.repliedbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.repliedbox input { width: 16px; height: 16px; accent-color: var(--sage); cursor: pointer; }
.card.replied .repliedbox { color: var(--sage-deep); }

.waiting { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }

.visit {
  width: 100%;
  min-height: 54px;
  font: 400 13px/1.45 var(--sans);
  padding: 8px 11px;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}

.visit::placeholder { color: var(--ink-faint); }
.visit:focus { border-color: var(--sage); outline: none; }
.visit.saved { border-color: var(--sage); background: var(--sage-wash); }

/* ---------------- language switch ---------------- */

.langbtn {
  font: 600 12.5px var(--sans);
  padding: 7px 14px;
  border: 1px solid var(--line-firm);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.langbtn:hover { color: var(--ink); border-color: var(--sage); }

.langlink {
  display: block;
  width: 100%;
  margin-top: 14px;
  font: 400 13px var(--sans);
  padding: 6px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.langlink:hover { color: var(--ink); }
