/* ============================================================
   Playbook design system
   Warm-neutral canvas, one confident green, hairline borders.
   ============================================================ */

:root {
  --ink:      #0e1512;
  --ink-2:    #56615a;
  --ink-3:    #8b958e;
  --line:     #e5e9e6;
  --line-2:   #f0f3f1;
  --canvas:   #f7f8f7;
  --surface:  #ffffff;

  --brand:      #0f7a52;
  --brand-ink:  #0b5d3e;
  --brand-tint: #eaf5f0;
  --brand-line: #cfe6dc;

  --amber:      #b4700f;
  --amber-tint: #fdf4e6;
  --danger:     #b23b32;
  --danger-tint:#fdeeec;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --sh-1: 0 1px 2px rgba(14, 21, 18, .05);
  --sh-2: 0 1px 3px rgba(14, 21, 18, .06), 0 8px 24px -8px rgba(14, 21, 18, .10);

  --nav-w: 246px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand-ink); text-underline-offset: 2px; }

::selection { background: var(--brand-tint); }

/* ------------------------------------------------------------ app shell */

.shell { display: flex; min-height: 100vh; }

.sidenav {
  width: var(--nav-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.lockup { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.lockup .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.14);
}
.lockup .mark svg { width: 17px; height: 17px; }
.lockup .name { font-weight: 700; letter-spacing: -.02em; font-size: 16.5px; }

.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 10px 6px;
}

.sidenav a.item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none;
  font-weight: 550; font-size: 14.5px;
  transition: background .12s ease, color .12s ease;
}
.sidenav a.item svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.sidenav a.item:hover { background: var(--line-2); color: var(--ink); }
.sidenav a.item.on { background: var(--brand-tint); color: var(--brand-ink); font-weight: 650; }
.sidenav a.item.on svg { opacity: 1; }
.sidenav a.item .pill {
  margin-left: auto; font-size: 11.5px; font-weight: 700;
  background: var(--line-2); color: var(--ink-3); padding: 1px 7px; border-radius: 999px;
}
.sidenav a.item.on .pill { background: #fff; color: var(--brand-ink); }

.sidenav .foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.sidenav .whoami { padding: 6px 10px; }
.sidenav .whoami .co { font-weight: 650; font-size: 14px; letter-spacing: -.01em; }
.sidenav .whoami .role { font-size: 12.5px; color: var(--ink-3); }
.sidenav .whoami .role.is-admin { color: var(--brand); font-weight: 650; }

.content { flex: 1; min-width: 0; }

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 34px 34px 90px;
}

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 27px; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 6px; }
.page-head p { color: var(--ink-2); margin: 0; max-width: 62ch; }

h2 { font-size: 17.5px; letter-spacing: -.015em; margin: 0 0 4px; }
.muted { color: var(--ink-3); font-size: 13.5px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 20px 22px;
}
.card + .card { margin-top: 14px; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.card-head .muted { margin-top: 2px; }

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

button, .btn {
  font: inherit; font-size: 14.5px; font-weight: 600; letter-spacing: -.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; min-height: 38px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--brand); color: #fff; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn { text-decoration: none; }
button:hover:not(:disabled), .btn:hover { background: var(--brand-ink); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Modifiers are element-agnostic so an <a class="btn ghost"> looks like a ghost
   button and not a primary one. */
.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.ghost:hover:not(:disabled) { background: var(--line-2); color: var(--ink); border-color: #d8ded9; }
.quiet { background: transparent; color: var(--ink-2); border-color: transparent; padding: 6px 9px; min-height: 32px; }
.quiet:hover:not(:disabled) { background: var(--line-2); color: var(--ink); }
.small { font-size: 13.5px; padding: 6px 11px; min-height: 32px; }
button.link { background: none; border: none; color: var(--brand-ink); padding: 2px; min-height: 0; text-decoration: underline; }
button.link:hover { background: none; color: var(--brand-ink); }
.danger { background: transparent; color: var(--danger); border-color: transparent; }
.danger:hover:not(:disabled) { background: var(--danger-tint); color: var(--danger); }
button svg, .btn svg { width: 15px; height: 15px; }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* below 16px iOS zooms in and never zooms back out */
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
textarea { min-height: 104px; resize: vertical; line-height: 1.55; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: right 17px center, right 12px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

/* --------------------------------------------------------------- notes */

.note { padding: 11px 14px; border-radius: var(--r-sm); font-size: 14.5px; display: flex; gap: 9px; align-items: flex-start; }
.note.err  { background: var(--danger-tint); color: #8d2f27; }
.note.ok   { background: var(--brand-tint);  color: var(--brand-ink); }
.note.warn { background: var(--amber-tint);  color: var(--amber); }
.note.info { background: var(--line-2);      color: var(--ink-2); }
.note.info strong { color: var(--ink); }
.note + * { margin-top: 14px; }

/* ------------------------------------------------------------ segmented */

.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 20px; flex-wrap: wrap; }
.seg button {
  background: transparent; color: var(--ink-2); border: none;
  min-height: 32px; padding: 6px 13px; font-size: 14px; border-radius: 7px;
}
.seg button:hover:not(.on) { background: rgba(255,255,255,.7); color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); font-weight: 650; }

/* ----------------------------------------------------------- progress */

.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s ease; }

.ring { --p: 0; width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line-2) 0);
  display: grid; place-items: center; }
.ring::after { content: ''; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); }
.ring.full { background: var(--brand); }
.ring.full::after { content: '✓'; color: var(--brand); font-size: 12px; font-weight: 800; display: grid; place-items: center; }

/* ---------------------------------------------------------- interview */

.track { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-bottom: 10px; overflow: hidden; }
.track > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: flex; align-items: center; gap: 14px; }
.track > summary::-webkit-details-marker { display: none; }
.track > summary:hover { background: #fcfdfc; }
.track .t-title { font-weight: 650; letter-spacing: -.01em; }
.track .t-blurb { color: var(--ink-3); font-size: 13.5px; }
.track .t-count { margin-left: auto; font-size: 13px; font-weight: 650; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.track .body { padding: 4px 20px 10px; border-top: 1px solid var(--line-2); }
.track[open] > summary { background: #fcfdfc; }

.q { padding: 18px 0; border-bottom: 1px solid var(--line-2); }
.q:last-child { border-bottom: none; }
.q .qt { font-weight: 600; margin-bottom: 9px; display: flex; gap: 9px; align-items: flex-start; letter-spacing: -.01em; }
.q .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; margin-top: 8px; }
.q .dot.done { background: var(--brand); }
.q .fu { margin-top: 12px; padding: 12px 0 0 15px; border-left: 2px solid var(--brand-line); }
.q .fu .qt { font-size: 14.5px; font-weight: 600; color: var(--brand-ink); }
.answer-foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.saved { font-size: 12.5px; color: var(--ink-3); }
.saved.on { color: var(--brand); }

/* ------------------------------------------------------------ markdown */

.md { line-height: 1.68; overflow-wrap: break-word; }
/* Worksheets are full of long ______ fill-in runs that cannot wrap on their own. */
.md p, .md li, .md td, .md h1, .md h2, .md h3 { overflow-wrap: break-word; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 23px; letter-spacing: -.02em; margin: 26px 0 10px; }
.md h2 { font-size: 18px; letter-spacing: -.015em; margin: 28px 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 15.5px; margin: 20px 0 6px; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { padding-left: 20px; margin: 0 0 12px; }
.md li { margin: 5px 0; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.md blockquote { margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--brand); background: var(--brand-tint); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.md blockquote p:last-child { margin: 0; }
.md code { overflow-wrap: anywhere; background: var(--line-2); padding: 1.5px 5px; border-radius: 5px; font-size: 13.5px; }
.md li.check { list-style: none; margin-left: -20px; }
.md .cb { color: var(--ink-3); font-size: 16px; margin-right: 2px; }
.md .ask { background: var(--amber-tint); color: var(--amber); border: 1px solid #f0dcb8; border-radius: 5px; padding: 0 5px; font-weight: 600; font-size: 14px; }

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

.chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden; }
.chat .log { padding: 20px; max-height: 56vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.bubble { overflow-wrap: break-word; max-width: 76%; padding: 11px 15px; border-radius: 16px; white-space: pre-wrap; font-size: 15px; }
.bubble .tag { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .5; margin-bottom: 4px; }
.bubble.homeowner { background: var(--line-2); border-bottom-left-radius: 5px; align-self: flex-start; }
.bubble.rep { background: var(--brand); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
.bubble.typing { display: flex; gap: 4px; align-items: center; padding: 15px; }
.bubble.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.3s infinite; }
.bubble.typing i:nth-child(2) { animation-delay: .2s; }
.bubble.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }
.chat .composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 10px; align-items: flex-end; background: #fcfdfc; }
.chat .composer textarea { min-height: 54px; background: var(--surface); }

/* -------------------------------------------------------------- grade */

.score { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.score .num {
  width: 76px; height: 76px; border-radius: 20px; flex: none;
  display: grid; place-items: center; font-size: 28px; font-weight: 800;
  letter-spacing: -.03em; color: #fff; font-variant-numeric: tabular-nums;
}
.crit { padding: 13px 0; border-bottom: 1px solid var(--line-2); }
.crit:last-child { border-bottom: none; }
.crit .head { display: flex; gap: 12px; align-items: center; font-weight: 600; font-size: 15px; }
.pips { margin-left: auto; display: flex; gap: 3px; flex: none; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.pips i.on { background: var(--brand); }
.pips.low i.on { background: var(--danger); }

.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 0 12px 9px; }
.tbl td { padding: 11px 12px; border-top: 1px solid var(--line-2); }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fcfdfc; }
.badge { display: inline-block; font-size: 12.5px; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.badge.good { background: var(--brand-tint); color: var(--brand-ink); }
.badge.bad { background: var(--danger-tint); color: var(--danger); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty svg { width: 30px; height: 30px; opacity: .35; margin-bottom: 10px; }

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

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: min(400px, 100%); }
.auth .lockup { justify-content: center; padding-bottom: 8px; }
.auth .tag { text-align: center; color: var(--ink-2); margin: 0 0 24px; }
.auth .card { padding: 24px; }
.auth footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--ink-3); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidenav {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 10px 14px; border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .sidenav .lockup { padding: 0 10px 0 0; }
  .sidenav .lockup .name { display: none; }
  .nav-label { display: none; }
  .sidenav a.item { padding: 7px 11px; white-space: nowrap; }
  .sidenav .foot { margin: 0 0 0 auto; padding: 0 0 0 10px; border: none; border-left: 1px solid var(--line); }
  .sidenav .whoami .co { display: none; }
  .page { padding: 22px 16px 70px; }
  .page-head h1 { font-size: 23px; }
  .bubble { max-width: 88%; }
  /* Wide tables scroll inside their card; the page itself never slides. */
  .tbl { min-width: 540px; }
  .tbl th, .tbl td { padding: 10px 8px; white-space: nowrap; }
  .tbl-scroll::after {
    content: 'swipe →'; display: block; text-align: right;
    font-size: 11px; color: var(--ink-3); padding: 2px 2px 0;
  }
}

@media print {
  .sidenav, .seg, button, .noprint, .page-head p { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  .md h2 { break-after: avoid; }
}

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