:root {
  font-family: "Inter", "Segoe UI", Roboto, sans-serif;
  color: #182e2a;
  background: #f4f6f2;
  font-synthesis: none;
  --green: #23594c;
  --quiet: #51665e;
  --line: #d5ded6;
  --paper: #fffefa;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .history:focus-visible {
  outline: 3px solid #498071;
  outline-offset: 3px;
}
button { border: 0; }
h1, h2, p, ol { margin: 0; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.045em; line-height: 1.18; }
h2 { font-size: 1.08rem; letter-spacing: -.025em; }
.topbar { background: #183e35; color: #fffefa; }
.topbar-inner {
  max-width: 1220px; min-height: 62px; margin: auto; padding: 10px 34px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 650; font-size: 1.07rem; white-space: nowrap; }
.brand-mark, .empty-mark { position: relative; }
.brand-mark { display: inline-block; width: 27px; height: 26px; }
.brand-mark::before, .brand-mark::after, .empty-mark::before, .empty-mark::after {
  content: ""; position: absolute; width: 67%; height: 56%;
  border: 2px solid; border-radius: 6px 6px 6px 1px; box-sizing: border-box;
}
.brand-mark::before, .empty-mark::before { left: 0; top: 1px; opacity: .64; }
.brand-mark::after, .empty-mark::after { right: 0; bottom: 1px; }
.brand-mark::after { background: #183e35; }
#account { display: flex; min-width: 0; align-items: center; gap: 16px; }
#account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account .text-button { white-space: nowrap; color: #d6e5da; background: transparent; }
#account .text-button:hover { color: white; }
#loading, noscript p { text-align: center; padding: 3rem .7rem; color: var(--quiet); }
#auth { max-width: 465px; margin: clamp(2rem, 11vh, 7rem) auto 3rem; padding: 0 16px; }
.auth-card { border: 1px solid var(--line); border-radius: 20px; background: var(--paper); padding: clamp(22px, 4vw, 38px); box-shadow: 0 15px 40px #223a2d09; }
.subheading, .field-hint, .empty p { color: var(--quiet); line-height: 1.55; }
.subheading { font-size: .94rem; margin-top: .7rem; }
.switcher { display: flex; gap: 3px; background: #eaf0e9; border-radius: 9px; padding: 4px; margin: 1.65rem 0; }
.switcher button { flex: 1; min-height: 37px; border-radius: 6px; background: none; color: var(--quiet); font-size: .9rem; font-weight: 600; }
.switcher button[aria-pressed="true"] { background: var(--paper); color: var(--green); box-shadow: 0 1px 4px #203d2e21; }
label { display: block; font-size: .86rem; font-weight: 650; margin: .85rem 0 .45rem; }
input, textarea {
  width: 100%; border: 1px solid #b6c6bb; border-radius: 8px; padding: 10px 12px;
  background: #fff; color: #172f29; line-height: 1.4;
}
textarea { resize: vertical; max-height: 35vh; min-height: 52px; }
.field-hint { margin-top: .4rem; font-size: .82rem; }
.primary, .soft-button, .text-button { border-radius: 8px; min-height: 40px; padding: 9px 15px; font-weight: 640; font-size: .89rem; }
.primary { color: #fff; background: var(--green); }
.primary:hover { background: #1c493e; }
.auth-card .primary { width: 100%; margin-top: 1.4rem; }
.soft-button { color: var(--green); background: #e3ede5; }
.soft-button:hover { background: #d7e6d9; }
.text-button { color: var(--quiet); background: transparent; }
.text-button:hover { background: #e6eee8; }
.small, .soft-button { min-height: 35px; padding: 7px 12px; }
.error { padding: 10px 12px; color: #842c22; background: #ffede6; border-radius: 8px; margin-top: 1rem; font-size: .9rem; overflow-wrap: anywhere; }
#workspace {
  display: grid; grid-template-columns: minmax(220px, 29%) minmax(0, 1fr);
  max-width: 1170px; width: calc(100% - 64px); height: min(830px, calc(100dvh - 112px));
  min-height: 485px; margin: 25px auto; overflow: hidden; border: 1px solid var(--line);
  border-radius: 16px; background: var(--paper);
}
.sidebar { min-height: 0; display: flex; flex-direction: column; background: #edf2eb; border-right: 1px solid var(--line); padding: 22px 16px; }
.sidebar-head, .form-actions, .composer-actions { display: flex; align-items: center; gap: 8px; }
.sidebar-head, .composer-actions { justify-content: space-between; }
.sidebar-head { margin-bottom: 12px; }
#new-chat-form { margin: 0 0 14px; }
.form-actions { margin-top: 8px; }
#chat-list { overflow-y: auto; min-height: 0; }
.chat-item { display: block; width: 100%; text-align: left; padding: 11px 13px; background: none; color: #30483d; border-radius: 7px; font-size: .94rem; overflow-wrap: anywhere; }
.chat-item:hover { background: #e3ebe1; }
.chat-item[aria-current="true"] { background: #d9e6db; color: #164638; font-weight: 650; }
.thread-pane { min-height: 0; display: flex; flex-direction: column; min-width: 0; }
.thread-pane > .error { margin: 10px 16px 0; }
.empty { margin: auto; width: min(510px, 100%); padding: 32px 18px; text-align: center; }
.empty-mark { width: 42px; height: 39px; margin: 0 auto 16px; color: #50806a; }
.empty-mark::after { background: var(--paper); }
.empty p { margin: .7rem 0 1.25rem; }
.sidebar-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#file-modes { margin-top: 8px; }
#file-modes .soft-button { max-width: 100%; color: #fff; background: var(--green); }
#file-modes .soft-button:hover { background: #1c493e; }
#own-file-help { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
#own-file-help h3 { margin: 0; font-size: .85rem; }
#own-file-help p { margin-top: 5px; color: var(--quiet); font-size: .8rem; line-height: 1.45; }
#source-help { color: var(--quiet); font-size: .78rem; line-height: 1.45; }
.sidebar-tools .text-button { min-height: 35px; padding: 7px 8px; }
#sample-guide { margin: 4px 0 12px; padding: 14px 16px; background: #f2f5ef; border: 1px solid var(--line); border-radius: 12px; }
#sample-guide h2 { font-size: .98rem; }
#sample-prompts { display: grid; gap: 6px; margin-top: 10px; }
#sample-prompts button { color: var(--green); background: var(--paper); border: 1px solid var(--line); border-radius: 7px; text-align: left; padding: 8px 11px; font-size: .86rem; line-height: 1.4; }
#sample-prompts button:hover:enabled { border-color: #699682; }
#sample-help, #sample-retry { margin-top: 8px; }
#thread { min-height: 0; height: 100%; display: flex; flex-direction: column; }
.thread-head { padding: 20px 26px; border-bottom: 1px solid var(--line); }
.thread-head h1 { font-size: 1.3rem; overflow-wrap: anywhere; }
.history { flex: 1; overflow: auto; min-height: 0; padding: 24px 26px; }
.empty-history { color: var(--quiet); font-size: .9rem; }
#messages { list-style: none; padding: 0; }
#messages li { background: #edf3ed; border-radius: 12px 12px 2px 12px; max-width: 88%; margin: 0 0 14px auto; padding: 12px 14px; width: fit-content; min-width: min(160px, 100%); }
.msg-meta { font-size: .74rem; color: #53685c; display: flex; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.msg-meta b { color: #344e3f; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.msg-file { margin-top: .35rem; font-size: .82rem; color: var(--green); overflow-wrap: anywhere; }
#message-form { padding: 12px 24px 18px; border-top: 1px solid var(--line); }
#message-form label { margin-top: 0; }
.attachment-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; margin-top: 6px; }
.attachment-row label { margin: 0; }
#message-file { max-width: 100%; min-width: 0; flex: 1 1 10rem; padding: 5px 7px; border: 1px solid #b6c6bb; border-radius: 6px; color: #172f29; background: white; font-size: .84rem; }
#attachment-status { color: #842c22; font-size: .8rem; }
.composer-actions { margin-top: 6px; }
#messages li.assistant { margin: 0 auto 14px 0; background: #f6f6f0; border: 1px solid var(--line); border-radius: 12px 12px 12px 2px; }
.turn-state { margin-top: .55rem; padding-top: .45rem; border-top: 1px solid var(--line); color: var(--quiet); font-size: .83rem; }
.turn-state.failed { color: #82402c; }
.model-notice { margin: 12px 16px 0; padding: 10px 12px; background: #f2eee1; color: #65512c; border-radius: 8px; font-size: .88rem; }
.send-buttons { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
#quota-warning:not(:empty) {
  margin-bottom: 6px; padding: 5px 9px; border-radius: 5px; text-align: right;
  color: #9d211c; background: #fff0ed; font-size: .85rem; font-weight: 650;
}
#provider-note { font-size: .78rem; }
#save-status { color: var(--quiet); font-size: .84rem; }
@media (max-width: 710px) {
  .topbar-inner { padding: 8px 17px; min-height: 54px; }
  #account { gap: 2px; font-size: .85rem; }
  #workspace { width: calc(100% - 20px); grid-template-columns: 1fr; grid-template-rows: auto minmax(395px, 1fr); min-height: 560px; height: auto; margin: 10px auto; }
  .sidebar { padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-head { margin-bottom: 3px; }
  #chat-list { max-height: 125px; }
  #thread { min-height: 420px; max-height: 80dvh; }
  .thread-head, .history, #message-form { padding: 15px; }
  .history { min-height: 120px; }
  #messages li { max-width: 95%; }
}


.sidebar { overflow: auto; }
#chat-list { flex: 1 1 auto; }
.account-tools { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
#daily-usage { margin: 0 0 .5rem; font-size: .81rem; }
#files-panel { margin-top: .6rem; }
#file-list { list-style: none; margin: .4rem 0; padding: 0; max-height: 155px; overflow: auto; }
#file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 4px; padding: .38rem 0; border-bottom: 1px solid var(--line); }
#file-list span { font-size: .83rem; overflow-wrap: anywhere; min-width: 0; }
#file-list button { font-size: .8rem; min-height: 32px; padding: 4px; }
#file-list small { grid-column: 1 / -1; color: var(--quiet); font-size: .78rem; overflow-wrap: anywhere; }
#file-list .source-link { justify-self: start; min-height: 24px; padding: 0; }
.source-link { background: transparent; color: var(--green); text-align: start; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.answer-sources { display: grid; gap: .3rem; margin-top: .7rem; font-size: .8rem; }
.answer-sources .source-link { justify-self: start; padding: 2px 0; }
#lead-dialog, #passage-dialog { width: min(40rem, calc(100% - 24px)); max-height: 82dvh; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; color: #172f29; background: var(--paper); }
#lead-dialog::backdrop, #passage-dialog::backdrop { background: rgb(24 46 42 / .45); }
.passage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.passage-header h2 { overflow-wrap: anywhere; }
#passage-list section { margin-top: .8rem; padding-top: .6rem; border-top: 1px solid var(--line); }
#passage-list h3 { margin: 0 0 .35rem; color: var(--green); font-size: .88rem; }
#passage-list p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.55; }
#upload-file { font-size: .81rem; padding: 5px; }
#files-panel .field-hint { font-size: .8rem; }
.message-label { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
#char-count { font-size: .78rem; margin: 0; }
#char-count.over-limit { color: #842c22; }
#message[aria-invalid="true"] { border-color: #842c22; }
button:disabled { cursor: default; }

#lead-open { margin-top: 6px; }
#lead-dialog { width: min(40rem, calc(100% - 24px)); overflow: auto; }
#lead-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
#lead-fields .consent-label { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
#lead-consent { width: 1rem; height: 1rem; flex: none; margin: 2px 0 0; accent-color: var(--green); }
#lead-submit, #lead-new { margin-top: .75rem; }
#lead-status { margin-top: 1rem; line-height: 1.5; }
.lead-contact-fields { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; }
.lead-contact-fields > div { min-width: 0; }
#lead-email:read-only { background: #f2f5ef; color: var(--quiet); }
.lead-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lead-actions > button { margin: .75rem 0 0; }
#lead-receipts { margin-top: .8rem; display: grid; gap: 8px; }
.lead-receipt { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 12px 15px; overflow-wrap: anywhere; }
#lead-current { background: #f1f6ef; border-color: #c3d5c6; }
.lead-receipt h3 { margin: 0 0 5px; font-size: .95rem; }
.lead-receipt p, .lead-receipt time { font-size: .8rem; color: var(--quiet); }
.lead-receipt blockquote { margin: 6px 0; white-space: pre-wrap; }
.lead-receipt ul { margin: 8px 0; padding-inline-start: 1.2rem; color: var(--green); font-weight: 600; font-size: .9rem; line-height: 1.5; }
#lead-workflow { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .55rem; }
#lead-workflow summary { cursor: pointer; width: fit-content; color: var(--green); font-size: .9rem; font-weight: 600; padding: .35rem 0; }
#lead-workflow a { display: block; }
#lead-workflow img { display: block; width: 100%; height: auto; margin-top: .4rem; border-radius: 6px; }
@media (max-width: 490px) {
  .lead-contact-fields { grid-template-columns: 1fr; gap: 0; }
}
