/* LooREADY palette only. Headings: Jaldi. Body: Sofia Pro (licensed) with a system fallback. */
:root {
  --lr-blue: #0083D0; --lr-green: #40B92E; --lr-white: #FFFFFF;
  --lr-blue-2: #D2F0FF; --lr-green-2: #E0F4E7;
  --ink: #1F2933; --ink-2: #52606D; --line: #E4E7EB;
  --head: 'Jaldi', 'Sofia Pro', system-ui, sans-serif;
  --body: 'Sofia Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--lr-white); color: var(--ink); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.eyebrow { font-size: 13px; letter-spacing: .02em; color: var(--lr-blue); font-weight: 600; }
.muted { color: var(--ink-2); }
.err { color: #B42318; min-height: 1.2em; font-size: 14px; margin: 4px 0 0; }
.link { background: none; border: 0; color: var(--lr-blue); padding: 8px; }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--st)) 20px calc(24px + var(--sb)); background: var(--lr-blue-2); }
.login-card { width: 100%; max-width: 380px; background: var(--lr-white); border-radius: 20px; padding: 28px 22px; }
.login-card h1 { font-family: var(--head); font-weight: 700; font-size: 34px; line-height: 1.1; margin: 2px 0 6px; }
.login-card .muted { margin: 0 0 18px; }
.login-card label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.login-card input:focus { outline: 2px solid var(--lr-blue); border-color: transparent; }
.btn-primary { width: 100%; margin-top: 8px; background: var(--lr-blue); color: #fff; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; font-size: 16px; }
.btn-primary:disabled { opacity: .6; }
.btn-primary.small { padding: 11px; font-size: 15px; margin: 0 0 8px; }

/* ---------- app shell ---------- */
.app { height: 100dvh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--st)) 8px 6px; border-bottom: 1px solid var(--line); background: var(--lr-white); }
.title { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; line-height: 1.15; }
.title .t { font-family: var(--head); font-weight: 700; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 12px; color: var(--ink); }
.icon-btn:active { background: var(--lr-blue-2); }

.install-tip { margin: 8px 12px 0; padding: 10px 36px 10px 12px; background: var(--lr-blue-2); border-radius: 12px; font-size: 14px; position: relative; }
.install-tip svg { vertical-align: -3px; color: var(--lr-blue); }
.install-tip .link { position: absolute; right: 2px; top: 2px; color: var(--ink-2); }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px 8px; }
.empty { max-width: 560px; margin: 8vh auto 0; text-align: left; }
.empty h2 { font-family: var(--head); font-weight: 700; font-size: 30px; line-height: 1.15; margin: 0 0 4px; }
.empty .muted { margin: 0 0 18px; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip { text-align: left; background: var(--lr-white); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; font-size: 15px; }
.chip:active { background: var(--lr-blue-2); border-color: var(--lr-blue-2); }

.msg { max-width: 720px; margin: 0 auto 14px; display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 88%; font-size: 16px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--lr-blue); color: #fff; padding: 10px 14px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; }
.msg.assistant .bubble { max-width: 100%; width: 100%; padding: 2px 2px; }
.msg.assistant.error .bubble { background: #FEF3F2; color: #912018; padding: 10px 14px; border-radius: 14px; }
.who-label { font-size: 13px; font-weight: 600; color: var(--lr-blue); margin-bottom: 2px; }

/* rendered markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3 { font-family: var(--head); font-weight: 700; line-height: 1.2; margin: 16px 0 6px; }
.md h1 { font-size: 22px; } .md h2 { font-size: 20px; } .md h3 { font-size: 18px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; } .md li { margin: 3px 0; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; background: var(--lr-blue-2); padding: 1px 5px; border-radius: 6px; }
.md pre { background: #F5F7FA; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--lr-green); background: var(--lr-green-2); border-radius: 0 8px 8px 0; }
.md a { color: var(--lr-blue); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.md .r { text-align: right; } .md .c { text-align: center; }
.md th { background: var(--lr-blue-2); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }

.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--lr-blue); opacity: .35; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }
.status-line { font-size: 13px; color: var(--ink-2); }

/* ---------- composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--sb)); border-top: 1px solid var(--line); background: var(--lr-white); }
.composer textarea { flex: 1; resize: none; font: inherit; font-size: 16px; line-height: 1.4; min-height: 46px; max-height: 140px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 22px; background: #F7F9FB; color: var(--ink); }
.composer textarea:focus { outline: none; border-color: var(--lr-blue); background: #fff; }
.send { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--lr-blue); color: #fff; display: grid; place-items: center; }
.send:disabled { background: var(--line); color: var(--ink-2); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(31, 41, 51, .35); z-index: 10; }
.drawer { position: fixed; z-index: 11; top: 0; bottom: 0; left: 0; width: min(84vw, 340px); background: var(--lr-white); display: flex; flex-direction: column; padding: calc(16px + var(--st)) 14px calc(12px + var(--sb)); box-shadow: none; border-right: 1px solid var(--line); }
.drawer-head { display: flex; flex-direction: column; margin-bottom: 14px; }
.drawer-head strong { font-family: var(--head); font-size: 22px; }
.thread-list { flex: 1; overflow-y: auto; margin: 4px -6px; }
.thread { display: flex; align-items: center; border-radius: 10px; }
.thread.active { background: var(--lr-blue-2); }
.thread button.open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 12px 8px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread button.del { background: none; border: 0; color: var(--ink-2); padding: 10px; font-size: 13px; }
.thread-empty { color: var(--ink-2); font-size: 14px; padding: 8px; }
.drawer-foot { display: flex; flex-direction: column; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 6px; }
.sheet { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; max-height: 85dvh; overflow-y: auto; background: var(--lr-white); border-radius: 20px 20px 0 0; padding: 14px 18px calc(18px + var(--sb)); }
#sheetScrim { z-index: 20; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h3 { font-family: var(--head); font-size: 22px; margin: 0; }
.sheet label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.sheet input[type=text], .sheet input[type=password] { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
.sheet .check { display: flex; gap: 8px; align-items: center; }
.ok { color: #1E7B13; font-size: 14px; }
.newpw { background: var(--lr-green-2); border-radius: 12px; padding: 12px; margin: 10px 0; font-size: 15px; }
.newpw code { font-size: 17px; font-weight: 700; user-select: all; -webkit-user-select: all; }
.urow { display: flex; align-items: center; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.urow .uname { flex: 1; min-width: 0; }
.urow .uname small { display: block; color: var(--ink-2); }
.urow button { background: var(--lr-blue-2); border: 0; border-radius: 10px; padding: 7px 10px; font-size: 13px; }
.section-label { font-weight: 600; margin: 18px 0 6px; }

@media (min-width: 900px) {
  .messages { padding: 24px; }
}
