:root {
  --ink: #1d2721;
  --muted: #708077;
  --line: #e2e9e3;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --green: #2e624a;
  --green-dark: #214b37;
  --green-soft: #eaf3ed;
  --shadow: 0 16px 42px rgb(25 48 35 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100svh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgb(65 130 95 / 35%); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.brand-mark, .account-avatar { display: grid; place-items: center; flex: 0 0 auto; background: var(--green); color: #fff; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; }
.boot-screen { display: grid; min-height: 100svh; place-content: center; justify-items: center; gap: 13px; color: var(--muted); }
.boot-screen p { margin: 0; font-size: 13px; }

.login-page { display: grid; min-height: 100svh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #e3efe6 0, transparent 34%), var(--paper); }
.login-card { width: min(100%, 420px); padding: clamp(26px, 6vw, 46px); border: 1px solid var(--line); border-radius: 24px; background: rgb(255 255 255 / 92%); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 13px; font-weight: 700; }
.login-copy { margin: 48px 0 28px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.login-copy h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -.04em; }
.login-copy p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 8px; color: #4a5b51; font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--ink); background: #fbfdfb; }
.login-form input:focus { border-color: #78a58a; box-shadow: 0 0 0 4px rgb(46 98 74 / 9%); }
.primary-button { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 12px; cursor: pointer; color: #fff; background: var(--green); font-size: 14px; font-weight: 800; }
.primary-button:hover { background: var(--green-dark); }
.primary-button span { font-size: 18px; }
.form-error { min-height: 18px; margin: 0; color: #a04439; font-size: 12px; line-height: 1.5; }
.login-note { display: flex; align-items: center; gap: 8px; margin: 30px 0 0; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5caa78; box-shadow: 0 0 0 4px #e4f2e8; }

.app-page { height: 100dvh; overflow: hidden; }
.app-shell { display: grid; height: 100%; grid-template-columns: 285px minmax(0, 1fr); }
.sidebar { display: flex; min-height: 100svh; flex-direction: column; padding: 24px 16px 16px; border-right: 1px solid var(--line); background: #f9fbf9; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup > div:last-child { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 14px; letter-spacing: -.02em; }
.brand-lockup span { color: var(--muted); font-size: 10px; }
.new-chat { display: flex; min-height: 46px; align-items: center; gap: 8px; margin: 28px 0 26px; padding: 0 15px; border: 1px solid #c9dbcf; border-radius: 12px; cursor: pointer; color: var(--green-dark); background: var(--green-soft); font-size: 13px; font-weight: 800; }
.new-chat:hover { background: #deeee3; }
.new-chat span { font-size: 20px; font-weight: 400; }
.conversation-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.conversation-heading small { display: grid; min-width: 22px; height: 20px; place-items: center; border-radius: 10px; background: #eef3ef; font-size: 10px; }
.conversation-list { display: grid; min-height: 0; gap: 3px; overflow: auto; }
.conversation-item { display: grid; gap: 5px; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; text-align: left; background: transparent; }
.conversation-item:hover { background: #f0f5f1; }
.conversation-item.selected { border-color: #d7e6da; background: #eaf3ed; }
.conversation-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conversation-item time { color: var(--muted); font-size: 10px; }
.empty-list { padding: 12px 8px; color: var(--muted); font-size: 12px; }
.sidebar-foot { display: grid; gap: 10px; margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); }
.text-button, .link-button { padding: 0; border: 0; cursor: pointer; color: var(--muted); background: transparent; font-size: 11px; text-align: left; }
.text-button:hover, .link-button:hover { color: var(--green); }
.account-row { display: flex; align-items: center; gap: 9px; padding-top: 8px; }
.account-avatar { width: 28px; height: 28px; border-radius: 50%; font-size: 11px; }
.account-name { overflow: hidden; flex: 1; text-overflow: ellipsis; white-space: nowrap; color: #4c5e53; font-size: 11px; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 0; border-radius: 9px; cursor: pointer; color: var(--muted); background: transparent; font-size: 18px; }
.icon-button:hover { background: #eaf1eb; color: var(--green); }
.sidebar { min-height: 0; height: 100%; }
.chat-panel { display: grid; min-width: 0; min-height: 0; height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto auto; background: var(--surface); }
.topbar { display: flex; min-height: 78px; align-items: center; justify-content: space-between; gap: 16px; padding: 15px clamp(20px, 5vw, 64px); border-bottom: 1px solid var(--line); }
.title-block { min-width: 0; }
.title-block > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.title-block h1 { overflow: hidden; margin: 3px 0 0; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; letter-spacing: -.03em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.model-pill, .top-actions select { min-height: 32px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fbfdfb; font-size: 10px; }
.model-pill { display: grid; place-items: center; padding: 0 10px; }
.top-actions select { padding: 0 8px; outline: 0; }
.message-scroller { overflow: auto; padding: 32px clamp(20px, 7vw, 110px) 24px; scroll-behavior: smooth; }
.message-row { display: flex; max-width: 820px; gap: 12px; margin: 0 auto 27px; }
.message-avatar { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 10px; color: #fff; background: var(--green); font-size: 10px; font-weight: 800; }
.message-row.user .message-avatar { color: var(--green-dark); background: #dfeee3; }
.message-content { min-width: 0; flex: 1; }
.message-meta { display: flex; align-items: baseline; gap: 8px; margin: 3px 0 8px; }
.message-meta strong { font-size: 12px; }
.message-meta time { color: var(--muted); font-size: 10px; }
.message-text { color: #34433a; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.message-row.user .message-text { color: var(--ink); }
.empty-chat { display: grid; min-height: 100%; place-content: center; justify-items: center; padding: 30px 0 80px; text-align: center; }
.empty-icon { display: grid; width: 52px; height: 52px; place-items: center; margin-bottom: 17px; border-radius: 17px; color: var(--green); background: var(--green-soft); font-size: 23px; }
.empty-chat h2 { margin: 0 0 9px; font-size: 21px; letter-spacing: -.03em; }
.empty-chat p { max-width: 350px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 25px; }
.suggestions button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: #557062; background: #fbfdfb; font-size: 11px; }
.suggestions button:hover { border-color: #b9d2bf; background: #f2f8f3; }
.notice { margin: 0 clamp(20px, 7vw, 110px) 8px; padding: 9px 12px; border-radius: 9px; color: #715c31; background: #fff8e9; font-size: 11px; }
.notice[hidden] { display: block; margin: 0; padding: 0; height: 0; }
.composer { width: min(100% - 40px, 820px); margin: 0 auto; padding: 11px 13px 9px; border: 1px solid #d5e1d7; border-radius: 16px; background: #fbfefb; box-shadow: 0 8px 24px rgb(42 77 54 / 7%); }
.composer textarea { display: block; width: 100%; max-height: 180px; min-height: 42px; resize: none; padding: 4px 3px 9px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 14px; line-height: 1.6; }
.composer textarea::placeholder { color: #98a79d; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #93a196; font-size: 10px; }
.send-button { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 10px; cursor: pointer; color: #fff; background: var(--green); font-size: 19px; font-weight: 700; }
.send-button:hover { background: var(--green-dark); }
.spinner { width: 14px; height: 14px; border: 2px solid rgb(255 255 255 / 40%); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.privacy-note { margin: 11px 20px max(14px, env(safe-area-inset-bottom)); color: #9aa79e; font-size: 10px; text-align: center; }
.privacy-note .link-button { color: inherit; font-size: inherit; text-decoration: underline; }
.mobile-only { display: none; }
.drawer-scrim { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 30px rgb(23 47 32 / 12%); }
  .drawer-open .sidebar { transform: translateX(0); }
  .drawer-open .drawer-scrim { display: block; position: fixed; z-index: 10; inset: 0; background: rgb(22 36 27 / 30%); }
  .mobile-only { display: grid; }
  .topbar { min-height: 68px; padding: 12px 16px; }
  .topbar > .mobile-only { flex: 0 0 auto; }
  .title-block { flex: 1; }
  .top-actions { flex: 0 0 auto; }
  .top-actions { gap: 5px; }
  .model-pill { display: none; }
  .top-actions select { max-width: 108px; }
  .message-scroller { padding: 24px 16px 18px; }
  .message-row { gap: 9px; margin-bottom: 23px; }
  .message-avatar { width: 27px; height: 27px; border-radius: 9px; }
  .message-text { font-size: 14px; line-height: 1.75; }
  .composer textarea, .login-form input { font-size: 16px; }
  .composer { width: calc(100% - 24px); border-radius: 15px; }
  .composer-foot span { font-size: 9px; }
  .notice { margin: 0 12px 8px; }
  .empty-chat { padding: 20px 12px 70px; }
  .empty-chat h2 { font-size: 19px; }
  .suggestions { display: grid; width: 100%; }
}

@media (max-width: 380px) {
  .topbar { gap: 7px; }
  .title-block h1 { font-size: 16px; }
  .top-actions select { max-width: 96px; padding-inline: 5px; }
  .privacy-note { font-size: 9px; }
}
