/* AI Accountant: a full-screen chat app under the site header. Sidebar of saved
   conversations on the left; on first open a centred "Where should we begin?" with the
   composer, then a conversation view with the composer docked at the bottom. */

/* Other pages always show a page scrollbar; reserve the same (blank) space here so the shared
   header sits in exactly the same place, without drawing a second, empty scrollbar.
   The chat itself scrolls inside .ai-scroll. */
html:has(body.ai-page) { overflow: hidden; scrollbar-gutter: stable; }
.ai-page { --hdr: 84px; background: #fff; overflow: hidden; }
.ai-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ai-app { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: calc(100vh - var(--hdr)); height: calc(100dvh - var(--hdr)); }

/* ---------- sidebar ---------- */
.ai-side { display: flex; flex-direction: column; min-height: 0; padding: 16px 12px; background: var(--alt); border-right: 1px solid var(--line); }
.ai-side-top { display: flex; align-items: center; gap: 8px; }
.ai-new { flex: 1; display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border: 0; border-radius: 14px; background: #fff; box-shadow: 0 0 0 1px var(--line); font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; transition: box-shadow .2s ease, background-color .2s ease; }
.ai-new svg { width: 18px; height: 18px; color: var(--brand); }
.ai-new:hover { box-shadow: 0 0 0 1px var(--brand); }
.ai-side-close { display: none; }
.ai-side-label { margin: 22px 10px 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ai-threads { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0 2px; list-style: none; }
.ai-thread { position: relative; display: flex; align-items: center; border-radius: 12px; }
.ai-thread a { flex: 1; min-width: 0; padding: 10px 40px 10px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.35; color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-thread a:hover { background: #fff; color: var(--ink); }
.ai-thread.is-active a { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.ai-thread-del { position: absolute; right: 6px; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s ease, background-color .15s ease, color .15s ease; }
.ai-thread-del svg { width: 15px; height: 15px; }
.ai-thread:hover .ai-thread-del, .ai-thread.is-active .ai-thread-del, .ai-thread-del:focus-visible { opacity: 1; }
.ai-thread-del:hover { background: #fdecec; color: #b42318; }
.ai-side-empty { margin: 4px 12px; font-size: 14px; color: var(--muted); }
.ai-side-note { margin: 12px 10px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.ai-scrim { display: none; }

/* ---------- main column ---------- */
.ai-main { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ai-topbar { display: none; }
.ai-scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.ai-log { width: 100%; max-width: 800px; margin: 0 auto; padding: 32px 24px 24px; }

.ai-empty { display: none; flex-direction: column; align-items: center; text-align: center; padding: 0 24px 26px; }
.ai-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 7px 14px; border-radius: 999px; background: var(--tint); font-size: 13.5px; font-weight: 600; color: var(--brand); }
.ai-eyebrow svg { width: 15px; height: 15px; }
.ai-empty h1 { font-size: clamp(28px, 3.4vw, 38px); line-height: 1.15; font-weight: 600; letter-spacing: -0.03em; color: var(--ink); }

/* empty state: heading and composer centred together, like a fresh ChatGPT page */
.ai-app.is-empty .ai-main { justify-content: center; }
.ai-app.is-empty .ai-scroll { display: none; }
.ai-app.is-empty .ai-empty { display: flex; animation: ai-rise .6s cubic-bezier(.22, .8, .24, 1) both; }
.ai-app.is-empty .ai-dock { padding-bottom: 12vh; }
.ai-app:not(.is-empty) .ai-suggest { display: none; }
.ai-app[data-state="loading"] .ai-empty, .ai-app[data-state="loading"] .ai-dock { visibility: hidden; }

/* ---------- composer ---------- */
.ai-dock { width: 100%; max-width: 800px; margin: 0 auto; padding: 8px 24px 16px; }
.ai-composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 22px; border-radius: 28px; background: #fff; box-shadow: 0 0 0 1px #d9dfea, 0 12px 32px -18px rgba(15, 30, 70, .35); transition: box-shadow .2s ease; }
.ai-composer:focus-within { box-shadow: 0 0 0 1px #b9c6e2, 0 14px 36px -18px rgba(15, 30, 70, .4); }
.ai-composer textarea { flex: 1; min-height: 28px; max-height: 220px; padding: 9px 0; border: 0; outline: 0; resize: none; background: transparent; font: inherit; font-size: 16px; line-height: 1.5; color: var(--ink); }
.ai-composer textarea::placeholder { color: #8b95ab; }
/* the rounded bar shows focus itself (see :focus-within above), so no inner outline */
.ai-composer textarea:focus, .ai-composer textarea:focus-visible { outline: none; box-shadow: none; }
.ai-send { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; cursor: pointer; transition: background-color .2s ease, transform .2s ease, opacity .2s ease; }
.ai-send svg { width: 19px; height: 19px; stroke-width: 2.4; }
.ai-send:hover:not(:disabled) { background: var(--brand); transform: translateY(-1px); }
.ai-send:disabled { background: #c9cfdb; cursor: default; }
.ai-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.ai-suggest button { padding: 9px 16px; border: 0; border-radius: 999px; background: var(--alt); box-shadow: 0 0 0 1px var(--line); font: inherit; font-size: 14px; color: var(--body); cursor: pointer; transition: background-color .2s ease, color .2s ease, box-shadow .2s ease; }
.ai-suggest button:hover { background: var(--tint); color: var(--brand); box-shadow: 0 0 0 1px #c9d6f3; }
.ai-disclaimer { margin-top: 10px; text-align: center; font-size: 12.5px; color: var(--muted); }
.ai-disclaimer a { color: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; transition: color .2s ease; }
.ai-disclaimer a:hover { color: var(--brand); }

/* ---------- messages ---------- */
.ai-msg { display: flex; margin: 0 0 26px; animation: ai-rise .35s ease both; }
.ai-msg--user { justify-content: flex-end; }
.ai-msg--user .ai-bubble { max-width: 78%; padding: 11px 18px; border-radius: 22px; background: var(--tint); color: var(--ink); font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg--bot { gap: 14px; align-items: flex-start; }
.ai-avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; margin-top: 2px; border-radius: 50%; background: linear-gradient(150deg, #587edb, #1445c2); color: #fff; }
.ai-avatar svg { width: 17px; height: 17px; }
.ai-answer { flex: 1; min-width: 0; font-size: 16.5px; line-height: 1.75; color: #2a3346; overflow-wrap: anywhere; }
.ai-answer p { margin: 0 0 12px; }
.ai-answer h3 { margin: 18px 0 8px; font-size: 18px; font-weight: 700; color: var(--ink); }
.ai-answer ul, .ai-answer ol { margin: 4px 0 14px; padding-left: 24px; }
.ai-answer ul { list-style: disc; }
.ai-answer ol { list-style: decimal; }
.ai-answer li { margin: 5px 0; padding-left: 4px; }
.ai-answer strong { color: var(--ink); font-weight: 600; }
.ai-answer a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.ai-answer > *:last-child { margin-bottom: 0; }
.ai-tools { display: flex; gap: 4px; margin-top: 8px; }
.ai-tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; transition: background-color .15s ease, color .15s ease; }
.ai-tool svg { width: 15px; height: 15px; }
.ai-tool:hover { background: var(--alt); color: var(--ink); }
.ai-error { color: #b42318; }

/* talk to a person / share contact / reCAPTCHA cards under an answer */
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ai-actions a { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--alt); box-shadow: 0 0 0 1px var(--line); font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; transition: background-color .2s ease, color .2s ease; }
.ai-actions a svg { width: 16px; height: 16px; color: var(--brand); }
.ai-actions a:hover { background: var(--tint); color: var(--brand); }
.ai-card { margin-top: 14px; padding: 18px; border-radius: 20px; background: var(--alt); box-shadow: 0 0 0 1px var(--line); }
.ai-card p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--body); }
.ai-card form { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-card input { flex: 1; min-width: 200px; height: 44px; padding: 0 16px; border: 1px solid #d3dcef; border-radius: 12px; background: #fff; font: inherit; font-size: 15px; color: var(--ink); }
.ai-card input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(20, 69, 194, .12); }
.ai-card button { height: 44px; padding: 0 18px; border: 0; border-radius: 12px; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.ai-card .ai-card-go { background: var(--brand); color: #fff; }
.ai-card .ai-card-skip { background: transparent; color: var(--muted); }
.ai-card-msg { margin-top: 8px !important; font-size: 13.5px !important; }

/* free plan: counter, upgrade card and dialog, locked states */
.ai-meter { margin-top: 10px; text-align: center; font-size: 13px; font-weight: 500; color: var(--body); }
.ai-meter a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ai-meter.is-low { color: #9a5b00; }
.ai-meter + .ai-disclaimer { margin-top: 4px; }
.ai-app.is-locked .ai-composer { background: var(--alt); box-shadow: 0 0 0 1px var(--line); }
.ai-app.is-locked .ai-composer textarea { cursor: not-allowed; }
.ai-card--upgrade { background: linear-gradient(150deg, #eef3fd 0%, #e2eafc 100%); box-shadow: 0 0 0 1px #d3dff7; }
.ai-card--upgrade strong { display: block; margin-bottom: 6px; font-size: 16px; color: var(--ink); }
.ai-card--upgrade .hv-btn { margin-top: 4px; }
.ai-new.is-locked::after, .ai-menu.is-locked::after { content: "Plan"; margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--tint); font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--brand); }
.ai-menu.is-locked { position: relative; }
.ai-menu.is-locked::after { position: absolute; top: 2px; right: -4px; margin: 0; padding: 1px 5px; font-size: 9px; }
.ai-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(11, 18, 32, .45); }
.ai-modal[hidden] { display: none; }
.ai-modal-card { width: min(460px, 100%); padding: 32px 30px 28px; border-radius: 28px; background: #fff; text-align: center; box-shadow: 0 40px 80px -30px rgba(10, 26, 63, .55); animation: ai-rise .3s ease both; }
.ai-modal-ic { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 18px; background: linear-gradient(150deg, #587edb, #1445c2); color: #fff; }
.ai-modal-ic svg { width: 26px; height: 26px; }
.ai-modal-card h2 { margin-top: 18px; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.ai-modal-card p { margin-top: 10px; font-size: 15px; line-height: 1.6; color: var(--body); }
.ai-modal-actions { display: grid; gap: 10px; margin-top: 22px; }
.ai-modal-actions .hv-btn { width: 100%; }

/* typing indicator */
.ai-typing { display: inline-flex; gap: 5px; padding: 12px 0; }
.ai-typing i { width: 8px; height: 8px; border-radius: 50%; background: #9aa7c4; animation: ai-blink 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes ai-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-msg, .ai-app.is-empty .ai-empty { animation: none; } .ai-typing i { animation: none; opacity: .6; } }

/* ---------- small screens: the sidebar slides in ---------- */
@media (max-width: 900px) {
  .ai-app { grid-template-columns: minmax(0, 1fr); }
  .ai-side { position: fixed; top: var(--hdr); left: 0; bottom: 0; z-index: 40; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .28s cubic-bezier(.22, .8, .24, 1); box-shadow: 18px 0 40px -24px rgba(10, 26, 63, .45); }
  .ai-app.side-open .ai-side { transform: none; }
  .ai-side-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
  .ai-side-close svg { width: 20px; height: 20px; }
  .ai-scrim { position: fixed; inset: var(--hdr) 0 0; z-index: 39; display: block; background: rgba(11, 18, 32, .35); }
  .ai-scrim[hidden] { display: none; }
  .ai-topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .ai-topbar-title { font-size: 15px; font-weight: 600; color: var(--ink); }
  .ai-menu { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
  .ai-menu svg { width: 21px; height: 21px; }
  .ai-menu:hover { background: var(--alt); }
}
@media (max-width: 720px) {
  .ai-page { --hdr: 72px; }
  .ai-log { padding: 20px 16px 16px; }
  .ai-dock { padding: 6px 12px 12px; }
  .ai-composer { padding-left: 16px; border-radius: 24px; }
  .ai-msg--user .ai-bubble { max-width: 88%; }
  .ai-msg--bot { gap: 10px; }
  .ai-avatar { width: 30px; height: 30px; }
  .ai-app.is-empty .ai-dock { padding-bottom: 6vh; }
  .ai-suggest button { font-size: 13.5px; }
}

/* ---------- inside the popup (the page loaded in a frame) ---------- */
html.ai-embed { scrollbar-gutter: auto; }
.ai-embed .hv-header, .ai-embed .hv-skip { display: none; }
.ai-embed .ai-page { --hdr: 0px; }
.ai-embed .ai-side { padding-top: 18px; }
@media (max-width: 900px) { .ai-embed .ai-topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 1; padding-right: 60px; background: #fff; } }


/* Delete-chat box: site card style, brand blue, pill buttons */
#ai-del { z-index: 110; background: rgba(11, 18, 32, .5); backdrop-filter: blur(3px); }
.ai-del-card { width: min(420px, 100%); padding: 34px 32px 28px; border-radius: 28px; box-shadow: 0 0 0 1px rgba(20, 69, 194, .10), 0 40px 80px -30px rgba(10, 26, 63, .55); }
.ai-del-ic { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 18px; background: var(--tint); color: var(--brand); box-shadow: 0 0 0 1px rgba(20, 69, 194, .12); }
.ai-del-ic svg { width: 26px; height: 26px; }
.ai-del-card h2 { margin-top: 18px; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.ai-del-card p { margin-top: 8px; font-size: 15px; line-height: 1.6; color: var(--body); }
.ai-del-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.ai-del-actions .hv-btn { width: 100%; justify-content: center; }
.ai-side-note a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ai-side-note a:hover { color: var(--brand); }

/* ---------- plans (Premium / Ultra) and credits ---------- */
.ai-plans-card { width: min(640px, 100%); text-align: center; }
.ai-plans-sub { margin-top: 8px; }
.ai-plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; text-align: left; }
.ai-plan { position: relative; display: flex; flex-direction: column; padding: 22px 20px 20px; border-radius: 22px; background: var(--alt); box-shadow: 0 0 0 1px var(--line); }
.ai-plan--best { background: var(--p-blue); box-shadow: 0 0 0 1.5px var(--brand); }
.ai-plan.is-current { box-shadow: 0 0 0 2px #1c6b4c; }
.ai-plan-tag { position: absolute; top: -11px; right: 16px; padding: 4px 12px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.ai-plan h3 { font-size: 19px; line-height: 1.2; font-weight: 700; color: var(--ink); }
.ai-plan-price { margin-top: 6px; font-size: 34px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
.ai-plan-price span { margin-left: 3px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.ai-plan ul { margin: 14px 0 18px; padding: 0; list-style: none; display: grid; gap: 8px; }
.ai-plan li { position: relative; padding-left: 22px; font-size: 14px; line-height: 1.45; color: var(--body); }
.ai-plan li::before { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 7px; border-left: 2.5px solid var(--brand); border-bottom: 2.5px solid var(--brand); transform: rotate(-45deg); }
.ai-plan .hv-btn { width: 100%; margin-top: auto; }
.ai-plans-status { min-height: 1.4em; margin-top: 16px; font-size: 14px; line-height: 1.5; color: var(--body); }
.ai-plans-status.is-note { padding: 10px 14px; border-radius: 14px; background: var(--tint); color: var(--ink); }
.ai-plans-close { margin-top: 8px; }
.ai-card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.ai-meter.is-low { color: #b45309; }
@media (max-width: 640px) { .ai-plan-grid { grid-template-columns: 1fr; } .ai-plan-tag { top: -10px; } }
.ai-plans-card { max-height: calc(100dvh - 40px); overflow-y: auto; }
@media (max-width: 640px) { .ai-plans-card { padding: 26px 18px 22px; } .ai-plans-card h2 { margin-top: 0; } }

/* Notice after coming back from the payment page */
.ai-toast { position: fixed; z-index: 120; top: 20px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px; background: #0b1220; color: #fff; font-size: 14.5px; line-height: 1.45; box-shadow: 0 18px 40px rgba(11, 18, 32, .28); }
.ai-toast[hidden] { display: none; }
