/* Harvey: phone first. Every input is 16px or larger (iOS never zooms), nothing is wider than
   the screen (no sideways scroll), and the notch and home bar are respected. WOM palette. */
@font-face { font-family: Gilroy; font-weight: 300; font-display: swap; src: url(/fonts/Gilroy-Light.otf) format("opentype"); }
@font-face { font-family: Gilroy; font-weight: 500; font-display: swap; src: url(/fonts/Gilroy-Medium.ttf) format("truetype"); }
@font-face { font-family: Gilroy; font-weight: 800; font-display: swap; src: url(/fonts/Gilroy-ExtraBold.otf) format("opentype"); }

:root {
  --bg: #faf7f2; --card: #ffffff; --ink: #1a2029; --ink-2: #2e3642; --dim: #7d766b; --line: #e8e2d6;
  --oak: #b45143; --oak-ink: #ffffff; --soft: #f3f1eb; --gold: #e8b252; --good: #3f7a55; --warn: #9a5b12; --bad: #b3372b;
  --bar: #1a2029; --bar-ink: #f3f1eb; --z-bubble: #1a2029; --z-ink: #f3f1eb;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14181f; --card: #1d222b; --ink: #f1ede5; --ink-2: #d9d3c8; --dim: #9c958a; --line: #2c333d; --soft: #232a34; --oak: #cf6a5b; --bar: #0f1217; --z-bubble: #cf6a5b; --z-ink: #fff; --good: #7fbf93; --warn: #e2a95a; --bad: #ec7b6e; color-scheme: dark; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden; max-width: 100%; }
body { font: 400 16px/1.5 Gilroy, -apple-system, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--oak); }
img, svg { max-width: 100%; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.app { min-height: 100vh; min-height: 100dvh; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 5; background: var(--bar); color: var(--bar-ink); padding: calc(var(--safe-t) + 10px) 16px 12px; display: flex; align-items: center; gap: 12px; }
.top .av { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: var(--soft); }
.top .who { min-width: 0; flex: 1; }
.top h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.top .st { font-size: 13px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: #8a8275; }
.dot.on { background: #6fcf8e; } .dot.work { background: var(--gold); } .dot.off { background: #e0685a; }
.top .back { background: none; border: 0; color: var(--bar-ink); font-size: 26px; line-height: 1; padding: 0 6px 0 0; }

/* Content */
.main { padding: 16px 16px calc(var(--safe-b) + 92px); max-width: 720px; margin: 0 auto; }
.h2 { font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 22px 2px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; min-width: 0; }
.card.tap { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; color: inherit; }
.card.tap .big { font-size: 30px; font-weight: 800; line-height: 1; min-width: 34px; }
.card.tap .lbl { flex: 1; min-width: 0; }
.card.tap .lbl b { display: block; font-weight: 800; }
.card.tap .lbl span { font-size: 14px; color: var(--dim); }
.card.tap .chev { color: var(--dim); font-size: 22px; }
.card.alert { border-color: var(--bad); }
.card.oak { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.muted { color: var(--dim); font-size: 14px; }
.small { font-size: 13px; color: var(--dim); }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 16px; line-height: 1.55; }
.prose.clamp { max-height: 15.5em; overflow: hidden; position: relative; }
.prose.clamp::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em; background: linear-gradient(transparent, var(--card)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { min-width: 0; }
.chip { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 99px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.chip.good { background: rgba(63,122,85,.14); color: var(--good); } .chip.warn { background: rgba(232,178,82,.2); color: var(--warn); } .chip.bad { background: rgba(179,55,43,.12); color: var(--bad); }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; min-height: 46px; font-weight: 800; font-size: 16px; background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--oak); color: var(--oak-ink); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; }
.btn.confirm { background: var(--good); color: #fff; }
.acts { display: flex; gap: 8px; margin-top: 12px; }
.acts .btn { flex: 1; }
.link { background: none; border: 0; color: var(--oak); font-weight: 800; padding: 8px 0; }

/* Forms */
.in, .ta { width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); outline: none; }
.in:focus, .ta:focus { border-color: var(--oak); }
.ta { resize: none; line-height: 1.5; min-height: 96px; overflow-wrap: anywhere; }
label.f { display: block; font-size: 14px; font-weight: 500; margin: 12px 0 6px; }

/* Drafts */
.draft .meta { font-size: 13px; color: var(--dim); overflow-wrap: anywhere; }
.draft .to { font-weight: 800; color: var(--ink); }
.draft .subj { font-weight: 800; margin: 8px 0 6px; overflow-wrap: anywhere; }
.draft .why { font-size: 14px; color: var(--dim); margin-top: 8px; overflow-wrap: anywhere; }
.draft .dtitle { font-size: 18px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.draft .dsub { font-size: 15px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.draft .kvs { margin-top: 10px; border-top: 1px solid var(--line); }
.draft .kv { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.draft .kv span { flex: 0 0 34%; color: var(--dim); }
.draft .kv b { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; white-space: pre-wrap; }
.draft .quote { margin-top: 10px; padding: 10px 12px; background: var(--soft); border-radius: 12px; font-size: 15px; max-height: 40vh; overflow: auto; }
.draft .ta.dt { margin-top: 10px; }
.draft .doclink { display: flex; align-items: center; justify-content: center; margin-top: 10px; text-decoration: none; color: var(--ink); }
.draft .effect { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(180,81,67,.09); color: var(--ink); font-size: 15px; font-weight: 500; }
.draft .effect::before { content: "When you tap: "; font-weight: 800; }
.draft.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--oak); } to { box-shadow: 0 0 0 0 transparent; } }

/* Segmented control (autonomy) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px; margin-top: 10px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 10px 4px; font-size: 14px; font-weight: 500; min-height: 42px; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 800; box-shadow: 0 0 0 1px var(--line); }
.seg button.on.never { color: var(--bad); } .seg button.on.auto { color: var(--good); }

/* Toggle */
.tg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.tg:first-child { border-top: 0; }
.tg input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: 0 0 50px; transition: background .15s; }
.tg input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tg input:checked { background: var(--good); } .tg input:checked::after { transform: translateX(20px); }

/* Chat */
.chat { display: flex; flex-direction: column; min-height: calc(100dvh - 64px - var(--safe-t)); }
.threads { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.threads::-webkit-scrollbar { display: none; }
.threads button { flex: 0 0 auto; max-width: 64vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1.5px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px; font-size: 14px; min-height: 38px; }
.threads button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.msgs { flex: 1; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.m { max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 16px; line-height: 1.5; }
.m.z { align-self: flex-end; background: var(--z-bubble); color: var(--z-ink); border-bottom-right-radius: 5px; }
.m.h { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.m.err { border-color: var(--bad); }
.m .t { display: block; font-size: 12px; opacity: .6; margin-top: 4px; }
.m .file { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--soft); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; white-space: normal; }
.typing { align-self: flex-start; font-size: 14px; color: var(--warn); background: rgba(232,178,82,.18); border-radius: 99px; padding: 7px 14px; }
.compose { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 12px calc(var(--safe-b) + 10px); display: flex; gap: 8px; align-items: flex-end; }
.compose .ta { min-height: 46px; max-height: 40vh; padding: 11px 14px; border-radius: 22px; }
.compose .btn { border-radius: 22px; flex: 0 0 auto; }
/* In chat the tab bar stays; it steps aside only while the keyboard is up. */
body.in-chat .compose { bottom: calc(var(--safe-b) + 62px); padding-bottom: 10px; }
body.in-chat.typing .tabs { display: none; }
body.in-chat.typing .compose { bottom: 0; padding-bottom: calc(var(--safe-b) + 10px); }
body.in-chat .chat { min-height: calc(100dvh - 64px - var(--safe-t) - 62px - var(--safe-b)); padding-bottom: calc(var(--safe-b) + 62px); }
body.in-chat.typing .chat { padding-bottom: 0; }

/* Bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px calc(var(--safe-b) + 6px); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--dim); font-size: 12px; font-weight: 500; padding: 6px 0; min-height: 50px; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--ink); font-weight: 800; }
.tabs .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--oak); color: #fff; font-size: 12px; font-weight: 800; line-height: 19px; text-align: center; }

/* Login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px); max-width: 420px; margin: 0 auto; }
.login img { width: 84px; height: 84px; border-radius: 22px; }
.login h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 16px 0 4px; }

/* Lists */
.list .item { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.list .item:first-child { border-top: 0; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .grow b { display: block; font-weight: 800; overflow-wrap: anywhere; }
.list .item .grow span { display: block; font-size: 14px; color: var(--dim); overflow-wrap: anywhere; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 84px); z-index: 20; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 13px 16px; font-size: 15px; font-weight: 500; text-align: center; animation: up .2s ease-out; }
body.in-chat .toast { bottom: calc(var(--safe-b) + 84px); }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }
.empty { text-align: center; color: var(--dim); padding: 36px 12px; }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--oak); border-radius: 50%; animation: s .8s linear infinite; vertical-align: -3px; }
@keyframes s { to { transform: rotate(360deg); } }
