:root {
  --paper: #ffffff;
  --paper-soft: #f6f9f8;
  --ink: #353e54;
  --muted: #5b6478;
  --hairline: #e2e2e2;
  --accent: #1f7f7e;
  --accent-deep: #176463;
  --accent-tint: #e1f4f4;
  --need: #353e54;
  --need-deep: #262d3e;
  --need-tint: #e7e9ef;
  --review: #36b6b5;
  --review-tint: #e4f5f5;
  --display: 'League Spartan', -apple-system, BlinkMacSystemFont, sans-serif;
  --sans: 'Raleway', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper-soft); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.1; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.demo-banner { background: var(--accent-tint); color: var(--accent-deep); font-size: 14px; padding: 8px 16px; text-align: center; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--paper); border-bottom: 1px solid var(--hairline); }
.logo { height: 30px; width: auto; display: block; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.ghost { background: transparent; border: 1.5px solid var(--accent); color: var(--accent-deep); }
.btn:disabled { opacity: 0.55; cursor: default; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; justify-self: start; }

/* Sign-in */
.signin { max-width: 1040px; margin: 0 auto; padding: 56px 24px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 56px; align-items: start; }
.signin h1 { font-size: clamp(34px, 5vw, 52px); letter-spacing: -0.01em; max-width: 14ch; }
.lede { margin-top: 16px; color: var(--muted); max-width: 46ch; }
.stack { display: grid; gap: 14px; margin-top: 32px; max-width: 380px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field input { border: 1.5px solid var(--hairline); border-radius: 10px; padding: 12px 14px; background: var(--paper); font-weight: 500; min-width: 0; width: 100%; }
.field input:focus { border-color: var(--accent); outline: none; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: 0.3em; }
.note { color: var(--muted); font-size: 14px; }
.error { color: var(--need-deep); font-size: 14px; margin-top: 12px; font-weight: 600; }

.demo-box { background: var(--paper); border: 1.5px dashed var(--accent); border-radius: 16px; padding: 24px; }
.demo-box h2 { font-size: 22px; }
.demo-box > p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.sample-list { display: grid; gap: 8px; margin-top: 16px; }
.sample { display: grid; text-align: left; gap: 2px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--paper-soft); cursor: pointer; }
.sample:hover { border-color: var(--accent); }
.sample strong { font-weight: 600; }
.sample span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.demo-code { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--hairline); display: grid; gap: 8px; justify-items: start; }
.demo-code p { font-size: 13px; color: var(--muted); }
.demo-code-value { font-family: var(--mono); font-size: 30px; letter-spacing: 0.25em; color: var(--accent-deep); }

/* Portal: one calm column. Status, next step, documents; Priya opens as a panel. */
.portal { max-width: 640px; margin: 0 auto; padding: 24px 16px 120px; display: grid; gap: 16px; }
.card { background: var(--paper); border: 1px solid var(--hairline); border-radius: 18px; padding: 22px; min-width: 0; }
.status-card h1 { font-size: 26px; outline: none; }
.steps { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; counter-reset: s; }
.steps li { position: relative; padding-top: 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.steps li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: 3px; background: var(--hairline); }
.steps li.done::before { background: var(--review); }
.steps li.now::before { background: var(--accent); }
.steps li.now { color: var(--ink); }
.status-line { margin-top: 16px; font-size: 17px; line-height: 1.5; }

.next-card { border: 1.5px solid var(--accent); box-shadow: 0 18px 40px -28px rgba(31, 127, 126, .55); }
.next-card h2 { font-size: 13px; font-family: var(--sans); font-weight: 700; color: var(--accent-deep); }
.next-text { margin-top: 6px; font-size: 18px; font-weight: 600; line-height: 1.4; }
.next-action { margin-top: 14px; }
.next-action > .btn { width: 100%; }
.need-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.need-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--paper-soft); }
.need-label { font-weight: 600; overflow-wrap: anywhere; }
.upload { position: relative; flex: none; }
.upload input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.upload span { display: inline-block; padding: 9px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; }
.upload:focus-within span { outline: 3px solid var(--accent-tint); outline-offset: 2px; }
#trayNote:empty { display: none; }
#trayNote { margin-top: 10px; }

.docs { padding: 0; }
.docs summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; font-family: var(--display); font-weight: 600; font-size: 18px; }
.docs summary::-webkit-details-marker { display: none; }
.docs summary::after { content: "+"; font-family: var(--sans); font-size: 22px; color: var(--accent-deep); margin-left: 8px; }
.docs[open] summary::after { content: "\2212"; }
.tray-count { margin-left: auto; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.docs .items, .docs .note { margin: 0 22px; }
.docs .note { padding-bottom: 18px; }
.items { list-style: none; padding: 0 0 12px; display: grid; }
.item { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--hairline); }
.item-label { font-weight: 600; overflow-wrap: anywhere; }
.item-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }
.dot.received { background: var(--accent); }
.dot.required { border: 3px solid var(--need); }
.dot.after_review { border: 2px dashed var(--review); }

.ask-open { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); border-radius: 999px; padding: 14px 22px; box-shadow: 0 14px 30px -12px rgba(31, 127, 126, .7); z-index: 5; }

.chat-sheet { position: fixed; inset: 0; z-index: 10; background: var(--paper); display: flex; flex-direction: column; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .chat-sheet { inset: auto 24px 24px auto; width: 420px; height: min(680px, calc(100vh - 48px)); border: 1px solid var(--hairline); border-radius: 18px; box-shadow: 0 30px 70px -30px rgba(53, 62, 84, .45); } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--hairline); }
.sheet-head h2 { font-size: 22px; }
.sheet-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 2px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.priya { background: var(--accent-tint); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.sent-to-sid { background: var(--review-tint); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices:empty { display: none; }
.choices .btn { min-width: 72px; }
.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 10px; scrollbar-width: none; }
.suggest:empty { display: none; }
.suggest::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--accent); background: var(--paper); color: var(--accent-deep); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; }
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; min-width: 0; border: 1.5px solid var(--hairline); border-radius: 12px; padding: 12px 14px; }
.composer input:focus { border-color: var(--accent); outline: none; }
body.chat-open { overflow: hidden; }
@media (min-width: 860px) { body.chat-open { overflow: auto; } }

@media (max-width: 860px) {
  .signin { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 32px 16px; }
  .top { padding: 12px 16px; }
  .logo { height: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  .chat-sheet { animation: rise .22s ease-out; }
  @keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* The thread takes focus after sign-in so screen readers land on Priya; keep that ring quiet. */
#thread:focus-visible { outline: 2px solid var(--accent-tint); outline-offset: 2px; }
