:root {
  color-scheme: light;
  --forest: #1b3d35;
  --forest-2: #285247;
  --sage: #a7c1b3;
  --mist: #f4f7f5;
  --surface: #ffffff;
  --ink: #1f2a28;
  --muted: #6b7773;
  --line: #dce5e0;
  --shadow: 0 22px 60px rgba(27,61,53,.12);
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", Inter, system-ui, sans-serif; color: var(--ink); background: var(--mist); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.loading-screen, .welcome { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.loading-screen { gap: 14px; align-content: center; color: var(--forest); }
.loading-screen p { color: var(--muted); }
.welcome { background: radial-gradient(circle at 20% 10%, #fff 0, transparent 38%), radial-gradient(circle at 90% 80%, #dbe9e2 0, transparent 42%), var(--mist); }
.welcome-card { width: min(620px, 100%); padding: clamp(24px,5vw,44px); border: 1px solid rgba(255,255,255,.9); border-radius: 28px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); text-align: center; }
.welcome-card h1 { margin: 24px 0 10px; font-size: clamp(27px,4vw,38px); line-height: 1.08; letter-spacing: -.035em; }
.welcome-card > p { color: var(--muted); line-height: 1.6; }
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; color: var(--forest); }
.brand-lockup.compact { gap: 9px; }
.wordmark { font-size: 25px; font-weight: 750; letter-spacing: -.04em; }
.compact .wordmark { font-size: 21px; }
.brand-mark { width: 32px; height: 32px; display:block; object-fit:contain; flex:none; }
.navigation-wordmark { display:block; width:min(188px,calc(100% - 44px)); height:auto; }
.welcome-logo { display:block; width:min(480px,100%); height:auto; margin:0 auto; }
.welcome-hero { display:block; width:100%; height:auto; max-height:245px; margin:20px auto 0; border-radius:18px; object-fit:cover; }
.primary-button { display: block; margin-top: 30px; padding: 15px 22px; border-radius: 12px; background: var(--forest); color: white; font-weight: 700; text-decoration: none; transition: transform .15s, background .15s; }
.primary-button:hover { background: var(--forest-2); transform: translateY(-1px); }
.auth-error { color: #9b3131 !important; margin-bottom: 0; }
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 310px minmax(0,1fr); background: var(--surface); }
.sidebar { height: 100dvh; display: flex; flex-direction: column; background: var(--forest); color: white; position: sticky; top: 0; z-index: 20; }
.sidebar-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar .brand-lockup { color: white; }
.group-picker { padding: 20px 18px 14px; }
.group-picker label, .conversation-nav h2 { display: block; margin: 0 0 8px 8px; color: rgba(255,255,255,.62); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.group-picker select { width: 100%; padding: 11px 36px 11px 12px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; color: white; background: rgba(255,255,255,.08); }
.group-picker-row { display:flex; gap:7px; }
.group-picker-row select { min-width:0; flex:1; }
.group-picker-row .mini-button { flex:none; height:41px; }
.conversation-nav { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
.conversation-nav section + section { margin-top: 24px; }
.nav-heading { display:flex; align-items:center; justify-content:space-between; padding-right:7px; }
.nav-heading h2 { margin-bottom:8px; }
.mini-button { width:28px; height:28px; border:0; border-radius:8px; color:white; background:rgba(255,255,255,.1); cursor:pointer; }
.nav-list { display: grid; gap: 3px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 0; border-radius: 10px; color: rgba(255,255,255,.82); background: transparent; text-align: left; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: rgba(167,193,179,.2); color: white; }
.nav-symbol { width: 22px; color: var(--sage); font-weight: 800; text-align: center; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 21px; margin-left: auto; padding: 2px 6px; border-radius: 999px; background: #dceadf; color: var(--forest); font-size: 11px; font-weight: 800; text-align: center; }
.nav-empty { padding: 7px 11px; color: rgba(255,255,255,.46); font-size: 13px; }
.account { display: flex; align-items: center; gap: 10px; padding: 15px 17px calc(15px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.1); }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border-radius: 50%; background: var(--sage); color: var(--forest); font-weight: 800; }
.account-copy { display: grid; min-width: 0; flex: 1; }
.account-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-copy span { color: rgba(255,255,255,.55); font-size: 11px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; font-size: 21px; }
.icon-button:hover { background: rgba(255,255,255,.09); }
.chat-pane { height: 100dvh; min-width: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; position: relative; background: white; }
.chat-header { min-height: 76px; display: flex; align-items: center; gap: 12px; padding: 13px clamp(18px,3vw,34px); border-bottom: 1px solid var(--line); }
.chat-header > div { min-width: 0; flex: 1; }
.chat-header h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; letter-spacing: -.015em; }
.chat-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.home-button { display:block; max-width:100%; padding:0; border:0; background:transparent; color:inherit; text-align:left; cursor:pointer; }
.connection { color: var(--muted); font-size: 12px; }
.connection.online { color: #32735d; }
.empty-state { display: grid; place-items: center; align-content: center; padding: 24px; text-align: center; }
.empty-state h2 { margin: 12px 0 7px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-tree { color: var(--sage); font-size: 72px; transform: rotate(180deg); }
.home-view { min-height:0; overflow-y:auto; padding:clamp(22px,4vw,48px); background:var(--mist); }
.home-inner { width:min(900px,100%); margin:0 auto; }
.home-intro { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:28px; }
.home-intro p { margin:0; color:var(--muted); font-size:16px; }
.home-inner section + section { margin-top:30px; }
.home-inner h2 { margin:0 0 10px; color:var(--forest); font-size:14px; letter-spacing:.02em; }
.inbox-list { overflow:hidden; border:1px solid var(--line); border-radius:16px; background:white; box-shadow:0 8px 26px rgba(27,61,53,.05); }
.inbox-row { width:100%; display:grid; grid-template-columns:44px minmax(0,1fr) auto; align-items:center; gap:12px; padding:14px 16px; border:0; background:white; color:var(--ink); text-align:left; cursor:pointer; }
.inbox-row + .inbox-row { border-top:1px solid var(--line); }
.inbox-row:hover { background:#fafcfb; }
.inbox-icon { width:42px; height:42px; display:grid; place-items:center; border-radius:13px; background:var(--mist); color:var(--forest); font-weight:800; }
.inbox-icon.conversation { border-radius:50%; background:#dfeae5; font-size:12px; }
.inbox-copy { min-width:0; }
.inbox-copy > div { display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.inbox-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.inbox-copy time { flex:none; color:var(--muted); font-size:11px; }
.inbox-copy p { margin:4px 0 0; overflow:hidden; color:var(--muted); font-size:13px; text-overflow:ellipsis; white-space:nowrap; }
.inbox-badge { min-width:23px; padding:4px 7px; border-radius:999px; background:var(--forest); color:white; font-size:11px; font-weight:800; text-align:center; }
.inbox-empty { margin:0; padding:22px 16px; color:var(--muted); text-align:center; }
.thread { min-height: 0; overflow-y: auto; padding: 22px clamp(18px,4vw,52px) 28px; scroll-behavior: smooth; }
#messages { max-width: 920px; margin: 0 auto; }
.message { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 11px; padding: 10px 0; }
.message + .message { border-top: 1px solid rgba(220,229,224,.55); }
.message-avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--mist); color: var(--forest); font-weight: 800; }
.message-avatar img { width:100%; height:100%; border-radius:inherit; object-fit:cover; }
.message-head { display: flex; align-items: baseline; gap: 8px; }
.message-head strong { font-size: 14px; }
.message-head time { color: var(--muted); font-size: 11px; }
.message-actions { display:flex; gap:6px; margin-left:auto; opacity:0; transition:opacity .15s; }
.message:hover .message-actions,.message:focus-within .message-actions { opacity:1; }
.message-actions button { padding:2px 5px; border:0; background:transparent; color:var(--muted); font-size:11px; cursor:pointer; }
.message-text { margin-top: 4px; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.deleted .message-text { color: var(--muted); font-style: italic; }
.text-button { display: block; margin: 0 auto 18px; border: 0; background: transparent; color: var(--forest); font-weight: 700; cursor: pointer; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px clamp(18px,4vw,52px) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: white; }
.compose-box { flex:1; min-width:0; border:1px solid var(--line); border-radius:14px; overflow:hidden; }
.compose-box:focus-within { border-color:var(--sage); box-shadow:0 0 0 3px rgba(167,193,179,.22); }
.format-toolbar { display:flex; gap:2px; padding:5px 7px; border-bottom:1px solid var(--line); background:var(--mist); }
.format-toolbar button { min-width:30px; height:28px; border:0; border-radius:6px; background:transparent; color:var(--ink); cursor:pointer; }
.format-toolbar button:hover { background:white; }
.message-input { min-height:44px; max-height:150px; overflow-y:auto; padding:11px 14px; outline:none; line-height:1.4; white-space:pre-wrap; }
.message-input:empty::before { content:attr(data-placeholder); color:#89938f; pointer-events:none; }
.attachment-preview { display:flex; align-items:center; gap:9px; padding:8px 10px; border-bottom:1px solid var(--line); font-size:12px; color:var(--muted); }
.attachment-preview img { width:42px; height:42px; border-radius:7px; object-fit:cover; }
.attachment-preview span { min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.attachment-preview button { border:0; background:transparent; color:#8b3434; cursor:pointer; }
.send-button { width: 46px; height: 46px; border: 0; border-radius: 14px; background: var(--forest); color: white; font-size: 22px; font-weight: 700; cursor: pointer; }
.send-button:disabled { opacity: .45; cursor: default; }
.toast { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); max-width: min(420px,calc(100% - 36px)); padding: 10px 14px; border-radius: 10px; color: white; background: #7d3030; box-shadow: var(--shadow); font-size: 13px; }
.sidebar-scrim, .mobile-only { display: none; }
.message-image { display:block; width:auto; max-width:min(680px,100%); max-height:520px; margin-top:9px; border-radius:13px; background:var(--mist); object-fit:contain; }
.modal { position:fixed; inset:0; z-index:50; display:grid; place-items:center; padding:18px; background:rgba(9,25,21,.52); }
.modal-card { width:min(610px,100%); max-height:min(760px,90dvh); overflow:auto; border-radius:20px; background:white; box-shadow:var(--shadow); }
.modal-card > header { position:sticky; top:0; z-index:2; display:flex; align-items:center; justify-content:space-between; padding:17px 20px; border-bottom:1px solid var(--line); background:white; }
.modal-card h2 { margin:0; font-size:20px; }
#modal-body { padding:18px 20px 22px; }
.tabs { display:flex; gap:5px; margin-bottom:18px; border-bottom:1px solid var(--line); }
.tabs button { padding:9px 13px; border:0; border-bottom:2px solid transparent; background:transparent; color:var(--muted); cursor:pointer; }
.tabs button.active { border-color:var(--forest); color:var(--forest); font-weight:700; }
.tool-form { display:grid; gap:13px; }
.inline-form { display:flex; align-items:end; gap:9px; }
.inline-form .field { flex:1; }
.field { display:grid; gap:5px; color:var(--muted); font-size:12px; font-weight:700; }
.field input,.field select { width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:white; outline:none; }
.field input:focus,.field select:focus { border-color:var(--sage); }
.primary-action,.secondary-action { padding:11px 15px; border:0; border-radius:9px; cursor:pointer; font-weight:700; }
.primary-action { background:var(--forest); color:white; }
.secondary-action { background:var(--mist); color:var(--forest); }
.tool-copy { margin:0 0 15px; color:var(--muted); line-height:1.5; }
.people-results,.bot-list { display:grid; gap:6px; margin-top:8px; }
.person-row,.bot-row { width:100%; display:flex; align-items:center; justify-content:space-between; padding:11px 12px; border:1px solid var(--line); border-radius:9px; background:white; text-align:left; }
.person-row { cursor:pointer; }
.person-row:hover { background:var(--mist); }
.bot-list h3 { margin:15px 0 3px; }
.bot-row > div { display:grid; gap:2px; }
.bot-row span { color:var(--muted); font-size:12px; }
.bot-row select { margin-left:auto; padding:7px; border:1px solid var(--line); border-radius:7px; background:white; }
.avatar-tools { margin-bottom:15px; }
.avatar-tools input { display:none; }
.pairing-result { margin-top:14px; padding:12px; border-radius:10px; background:var(--mist); }
.pairing-result p { margin:0 0 7px; color:var(--muted); font-size:12px; }
.pairing-result code { display:block; overflow-wrap:anywhere; user-select:all; }
@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: min(88vw,330px); position: fixed; left: 0; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 15; border: 0; background: rgba(9,25,21,.38); }
  .app-shell.sidebar-open .sidebar-scrim { display: block; }
  .chat-header { padding-left: 12px; }
  .connection { display: none; }
  .thread { padding-top: 12px; }
  .home-view { padding:18px 12px 28px; }
  .home-intro { margin:4px 4px 20px; }
  .inbox-row { padding:13px 12px; }
  .format-toolbar button { min-width:28px; }
  .format-toolbar button:last-of-type { margin-left:auto; }
  .inline-form { display:grid; }
  .message-actions { opacity:1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
