/* Hearth Binder app styles. Based on the mock-v2 wireframe. No inline styles anywhere (strict CSP). */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2a2e;
  --muted: #5d6b70;
  --line: #e4e0d6;
  --brand: #1d7a6e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --warn: #b5651d;
  --warn-soft: #fbeedd;
  --due: #b23b3b;
  --due-soft: #fbe5e3;
  --ok: #2f7d32;
  --ok-soft: #e4f3e4;
  --ai: #4b4fb8;
  --ai-soft: #ecedfb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }


/* App shell: mobile-first */
.shell { min-height: 100vh; padding-bottom: 76px; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: .95rem;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
main { padding: 6px 16px 24px; max-width: 1100px; }
.page-head { margin: 8px 0 14px; }

/* Bottom tab bar (phone) */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px 10px;
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .7rem; color: var(--muted); padding: 4px 0;
}
.tabs a .ic { font-size: 1.25rem; line-height: 1; }
.tabs a.on { color: var(--brand); font-weight: 600; }
.tabs a.ask .ic {
  background: var(--ai); color: #fff; border-radius: 50%;
  width: 34px; height: 34px; display: grid; place-items: center; margin-top: -14px;
  box-shadow: 0 2px 8px rgba(75,79,184,.35); font-size: 1rem;
}
.side { display: none; }

/* Cards and lists */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { font-size: .85rem; color: var(--muted); }
.list .amt { font-weight: 700; white-space: nowrap; }
.chip-ic {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); font-size: 1.1rem; flex: none;
}
.pill {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap;
}
.pill.due { background: var(--due-soft); color: var(--due); }
.pill.soon { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--brand-soft); color: var(--brand); }
.pill.ai { background: var(--ai-soft); color: var(--ai); }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.kv div span { display: block; font-size: .78rem; color: var(--muted); }
.kv div b { font-weight: 600; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: .75rem; color: var(--muted); }

.hello { background: var(--brand); color: #fff; border: 0; }
.hello .muted { color: #d5ece8; }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-size: 1rem; font-weight: 600;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; width: 100%;
}
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--due); border: 1px solid #e9b9b5; }
.btn.sm { white-space: nowrap; width: auto; padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.toggle:first-of-type { border-top: 0; }
.sw { width: 44px; height: 26px; border-radius: 13px; background: var(--brand); position: relative; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; }
.sw.off { background: #cfcac0; }
.sw.off::after { right: auto; left: 3px; }

.never {
  background: var(--warn-soft); border: 1px solid #f0d2ae; border-radius: 12px;
  padding: 12px 14px; font-size: .85rem;
}
.never ul { margin: 6px 0 0; padding-left: 18px; }

/* Sign-in */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 20px; }
.auth .logo { justify-content: center; font-size: 1.2rem; margin-bottom: 18px; }
.auth h1 { text-align: center; font-size: 1.6rem; }
.auth .lead { text-align: center; color: var(--muted); margin-bottom: 20px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.trust { list-style: none; padding: 0; margin: 22px 0 0; font-size: .85rem; color: var(--muted); }
.trust li { padding: 4px 0; }

/* Onboarding */
.steps { display: flex; gap: 6px; margin: 6px 0 16px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--brand); }
.step { display: none; }
.step.on { display: block; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.quick span { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: .85rem; }
.quick span.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* Assistant */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 16px; font-size: .95rem; }
.msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.guard { border-color: #f0d2ae; background: #fffaf3; }
.src { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.src a { font-size: .72rem; background: var(--ai-soft); color: var(--ai); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.suggest { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 4px 0 10px; }
.suggest span { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: .85rem; }
.composer {
  position: sticky; bottom: 76px; display: flex; gap: 8px; margin-top: 14px;
  background: var(--bg); padding: 8px 0;
}
.composer input { border-radius: 999px; }
.composer .btn { width: auto; border-radius: 999px; background: var(--ai); }
.ai-note { font-size: .75rem; color: var(--muted); text-align: center; margin-top: 6px; }

.fab {
  display: none;
}

/* Desktop */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 230px 1fr; padding-bottom: 0; }
  .tabs { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
    border-right: 1px solid var(--line); background: #fbfaf7; min-height: 100vh;
    position: sticky; top: 0; height: 100vh;
  }
  .side .logo { padding: 4px 10px 18px; }
  .side a { padding: 9px 12px; border-radius: 10px; color: var(--ink); display: flex; gap: 10px; align-items: center; }
  .side a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side .ask-link { margin-top: 10px; background: var(--ai); color: #fff; justify-content: center; font-weight: 600; }
  .side .ask-link.on { background: var(--ai); color: #fff; }
  .side .foot { margin-top: auto; font-size: .75rem; color: var(--muted); padding: 10px; }
  .top { padding: 18px 28px 4px; }
  .top .logo { visibility: hidden; }
  main { padding: 6px 28px 40px; }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .grid3 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }

  .composer { bottom: 0; }
  .chat-wrap { max-width: 760px; }
  .auth { padding-top: 60px; }
  .ob { max-width: 560px; }
}

/* Systems, documents and AI-read confirm flows */
.age { font-size: .78rem; color: var(--muted); }
.doc-thumb {
  width: 100%; max-width: 260px; aspect-ratio: 8.5 / 11; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 14px; box-shadow: var(--shadow); font-size: .62rem; color: #8a8f91;
  display: flex; flex-direction: column; gap: 6px; margin: 0 auto 12px;
}
.doc-thumb b { color: #444; font-size: .75rem; }
.doc-thumb i { display: block; height: 6px; border-radius: 3px; background: #ecebe6; }
.doc-thumb .redact { background: #222; height: 9px; width: 60%; }
.doc-thumb .hl { outline: 2px solid var(--ai); outline-offset: 2px; border-radius: 3px; }
.field { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.conf { font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; margin-bottom: 10px; }
.conf.hi { background: var(--ok-soft); color: var(--ok); }
.conf.lo { background: var(--warn-soft); color: var(--warn); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.box { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); flex: none; position: relative; margin-top: 2px; }
.box::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.box.off { background: #fff; border: 2px solid #cfcac0; }
.box.off::after { display: none; }
.choice { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; display: block; color: var(--ink); }
.choice.rec { border: 2px solid var(--brand); }
.choice b { display: block; margin-bottom: 2px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #cfcac0; flex: none; margin-top: 2px; }
.dot.on { border: 6px solid var(--brand); }
.disclose { background: var(--ai-soft); border: 1px solid #d6d8f5; border-radius: 12px; padding: 12px 14px; font-size: .82rem; }
.timeline .list li { align-items: flex-start; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; font-size: .72rem; }
.cal .dow { text-align: center; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal .d { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 52px; padding: 3px 4px; }
.cal .d.x { background: transparent; border-color: transparent; }
.cal .d .n { font-weight: 600; }
.cal .d.today { border: 2px solid var(--brand); }
.cal .ev { display: block; border-radius: 4px; padding: 1px 3px; margin-top: 2px; font-size: .62rem; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ev.bill { background: var(--brand-soft); color: var(--brand); }
.ev.appt { background: var(--ai-soft); color: var(--ai); font-weight: 600; }
.ev.task { background: var(--warn-soft); color: var(--warn); }
.ev.done { background: #eee; color: #888; text-decoration: line-through; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .75rem; margin-top: 8px; }
.legend span { display: inline-flex; gap: 4px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
@media (min-width: 900px) { .cal { font-size: .8rem; } .cal .d { min-height: 84px; } .cal .ev { font-size: .72rem; } }

/* Messages */
.thread { display: flex; flex-direction: column; gap: 10px; }
.m { display: flex; gap: 8px; align-items: flex-end; }
.m.mine { flex-direction: row-reverse; }
.m .avatar { width: 28px; height: 28px; font-size: .75rem; flex: none; }
.m .b { max-width: 80%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 9px 12px; font-size: .92rem; }
.m.mine .b { background: var(--brand-soft); border-color: #c5e4de; }
.m .meta { font-size: .7rem; color: var(--muted); margin-top: 4px; }
.tag { display: inline-flex; gap: 4px; align-items: center; font-size: .72rem; font-weight: 600; background: #f3efe6; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 2px 8px; margin: 6px 4px 0 0; }
.tag.appt { background: var(--ai-soft); color: var(--ai); border-color: #d6d8f5; }
.seg { display: flex; background: #ebe7dd; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg span { flex: 1; text-align: center; padding: 7px; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg span.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ */
/* App additions (replace the mock's inline styles)                    */
/* ------------------------------------------------------------------ */
[hidden] { display: none !important; }
button { font: inherit; }
button.btn { -webkit-appearance: none; appearance: none; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ai { background: var(--ai); }
.btn.link { background: none; color: var(--brand); padding: 0; width: auto; font-weight: 600; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mb0 { margin-bottom: 0; } .mb12 { margin-bottom: 12px; } .m0 { margin: 0; }
.center { text-align: center; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.spacer { height: 10px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.page-head.head-row h1 { margin: 0; }
.title-link { color: var(--ink); font-weight: 600; }
.ai-card { background: var(--ai-soft); border-color: #d6d8f5; }
.ai-card h2 { color: var(--ai); }
.brand-card { background: var(--brand-soft); border-color: #c5e4de; box-shadow: none; }
.rec-card { border: 2px solid var(--brand); }
.avatar.b { background: #f3e6d3; color: #8a5a1c; }
.top .avatars { display: flex; }
.top .avatars .avatar + .avatar { margin-left: -8px; border: 2px solid var(--bg); }
.m .avatar.b { background: #f3e6d3; color: #8a5a1c; }
.home-msg { display: flex; gap: 8px; align-items: flex-start; }
.home-msg .b { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: .9rem; }
.err { color: var(--due); font-size: .8rem; margin-top: 4px; }
.ok-text { color: var(--ok); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--due); color: #fff; font-size: .65rem; font-weight: 700; margin-left: 4px; }
.tabs .badge { position: absolute; margin: -4px 0 0 18px; }
.tabs a { position: relative; }
.empty { color: var(--muted); font-size: .9rem; padding: 10px 0; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: .85rem; cursor: pointer; color: var(--ink); }
.chip-btn.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer; }
.quick button.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.suggest button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: .85rem; cursor: pointer; }
.seg button { flex: 1; text-align: center; padding: 7px; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); background: none; border: 0; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.check input[type=checkbox] { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--brand); }
.check .grow { flex: 1; min-width: 0; }
.check input.inline-edit { padding: 6px 8px; margin-top: 4px; font-size: .9rem; }
.toggle input[type=checkbox] { width: 44px; height: 26px; flex: none; accent-color: var(--brand); }
.radio input { margin-top: 4px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.cal-nav { display: flex; gap: 8px; align-items: center; }
.cal .d.other { opacity: .45; }
.cal .d button.ev { border: 0; width: 100%; text-align: left; cursor: pointer; font: inherit; }
.feed-url { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; word-break: break-all; background: #fbfaf7; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; }
.danger-zone { border-color: #e9b9b5; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
.small-list li { padding: 8px 0; }
.kv.one { grid-template-columns: 1fr; }
.thumb { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; margin: 0 auto 10px; }
.redact-wrap { position: relative; touch-action: none; }
.redact-wrap canvas { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; cursor: crosshair; }
.msg.bot.thinking { color: var(--muted); font-style: italic; }
.chat-empty { color: var(--muted); font-size: .9rem; }
.never-inline { font-size: .78rem; color: var(--muted); }
.file-link { font-weight: 600; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* Sheet (modal form) */
dialog.sheet { border: 0; padding: 0; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; max-height: 92vh; background: var(--card); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(20, 28, 30, .45); }
dialog.sheet form { padding: 18px 16px 20px; overflow-y: auto; max-height: 92vh; }
dialog.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
dialog.sheet .sheet-head h2 { margin: 0; }
dialog.sheet .x { background: none; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
dialog.sheet .cb { display: flex; gap: 10px; align-items: center; margin: 14px 0 0; font-weight: 600; font-size: .9rem; }
dialog.sheet .cb input { width: 20px; height: 20px; accent-color: var(--brand); }
dialog.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
dialog.sheet .actions .btn { flex: 1; }
@media (min-width: 900px) { dialog.sheet { border-radius: 18px; margin: auto; } }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .9rem; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
.toast.bad { background: var(--due); }
@media (min-width: 900px) { .toast { bottom: 30px; } }

/* Install banner */
.install { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
button.choice { width: 100%; text-align: left; font: inherit; cursor: pointer; }
label.choice { cursor: pointer; font-weight: 600; }
label.choice .small { font-weight: 400; display: block; }
label.btn { margin: 0; }
.seg a { flex: 1; text-align: center; }
.composer select { width: auto; max-width: 34%; border-radius: 999px; }
.legend i.ev { display: inline-block; margin: 0; padding: 0; }
