:root {
  color-scheme: light;
  --bg: #f3f3ef;
  --panel: #fbfbf8;
  --surface: #fff;
  --surface-soft: #f5f5f1;
  --line: #e6e6df;
  --line-strong: #d8d8d0;
  --text: #20231f;
  --muted: #71756e;
  --subtle: #9a9e96;
  --accent: #425c4b;
  --accent-soft: #e9efe9;
  --green: #4f745a;
  --danger: #a94d4d
}

* { box-sizing: border-box }
html { overflow-x: hidden }
button,textarea { font: inherit; touch-action: manipulation }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  font-family: Inter,Geist,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased
}

.shell {
  width: min(1440px,100%);
  height: 100vh;
  height: 100dvh;
  margin: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 340px minmax(0,1fr);
  gap: 18px
}

.identity-rail,.chat {
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(32,35,31,.03),0 12px 32px rgba(32,35,31,.04)
}

.identity-rail {
  padding: 30px;
  display: flex;
  flex-direction: column;
  border-radius: 22px
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none
}

.brand>span:last-child,.rail-footer>span:last-child { display: grid; gap: 3px }
.brand b { font-size: 14px; font-weight: 650; letter-spacing: -.01em }
.brand small,.rail-footer small { color: var(--muted); font-size: 11px; line-height: 1.4 }

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--text);
  box-shadow: 0 4px 12px rgba(32,35,31,.12);
  font-size: 12px;
  font-weight: 700
}

.rail-intro { margin-top: clamp(64px,10vh,112px) }
.intro-label,.welcome-label { margin: 0; color: var(--accent); font-size: 12px; font-weight: 600 }

.rail-intro h1 {
  margin: 13px 0 19px;
  font-size: clamp(31px,2.5vw,42px);
  font-weight: 530;
  line-height: 1.08;
  letter-spacing: -.045em
}

.rail-intro h1 em { color: var(--accent); font-style: normal }
.rail-intro>p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75 }
.knowledge-panel { margin-top: auto }
.knowledge-panel>p { margin: 0 0 12px 2px; color: var(--muted); font-size: 12px; font-weight: 600 }

.knowledge-card {
  margin-top: 7px;
  padding: 12px 10px;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 11px;
  border-radius: 13px;
  color: var(--subtle)
}

.knowledge-card.active { color: var(--text); background: var(--surface-soft) }
.knowledge-card>span:nth-child(2) { min-width: 0; display: grid; gap: 3px }
.knowledge-card b { font-size: 12px; font-weight: 600 }

.knowledge-card small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap
}

.knowledge-card i { width: 7px; height: 7px; border-radius: 50%; background: #c8cac4 }
.knowledge-card.active i { background: var(--green) }

.source-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent);
  background: var(--surface);
  font-size: 9px;
  font-weight: 700
}

.rail-footer {
  margin-top: 22px;
  padding-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line)
}

.rail-footer b { font-size: 11px; font-weight: 600 }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(79,116,90,.09) }

.chat {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  border-radius: 22px
}

.chat-header {
  min-height: 82px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line)
}

.chat-header>div:first-child { display: grid; gap: 4px }
.chat-header h2 { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -.015em }
.chat-header span { color: var(--muted); font-size: 11px }
.privacy-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px }
.privacy-note span { width: 6px; height: 6px; border-radius: 50%; background: var(--green) }

.messages {
  min-height: 0;
  padding: 42px clamp(26px,5vw,78px);
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-color: #d3d4ce transparent
}

.welcome {
  height: 100%;
  min-height: 420px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center
}

.orb {
  width: 72px;
  height: 72px;
  margin-bottom: 25px;
  display: grid;
  place-items: center;
  border-radius: 21px;
  color: #fff;
  background: var(--text);
  box-shadow: 0 12px 30px rgba(32,35,31,.13)
}

.orb span { font-size: 14px; font-weight: 700 }

.welcome h2 {
  margin: 11px 0 0;
  font-size: clamp(32px,4vw,50px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.05em
}

.welcome>p:not(.welcome-label) { max-width: 540px; margin: 17px auto 0; color: var(--muted); font-size: 13px; line-height: 1.7 }

.suggestions {
  width: min(660px,100%);
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px
}

.suggestions button {
  min-width: 0;
  min-height: 56px;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #4c504a;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(32,35,31,.025);
  cursor: pointer;
  font-size: 11px;
  font-weight: 550;
  text-align: left;
  transition: border-color .18s ease,box-shadow .18s ease,transform .18s ease
}

.suggestions button span { color: var(--subtle); font-size: 9px; font-weight: 500 }
.suggestions button:hover { border-color: var(--line-strong); box-shadow: 0 6px 18px rgba(32,35,31,.06); transform: translateY(-1px) }

.message { display: flex; gap: 11px; margin-bottom: 24px; animation: enter .2s ease-out }
.message.user { justify-content: flex-end }
.message-content { min-width: 0; max-width: min(76ch,82%) }
.user .message-content { display: flex; justify-content: flex-end }

.avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--text);
  font-size: 9px;
  font-weight: 700
}

.bubble {
  max-width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 5px 16px 16px;
  color: #3c403a;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere
}

.user .bubble { border: 0; border-radius: 16px 16px 5px 16px; color: #fff; background: var(--accent); box-shadow: 0 7px 18px rgba(66,92,75,.12) }
.response-sources { margin: 0 0 8px 2px; display: flex; flex-wrap: wrap; gap: 6px }

.source-tag {
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 9px;
  font-weight: 550
}

.source-tag:before { width: 5px; height: 5px; border-radius: 50%; background: var(--subtle); content: "" }
.source-tag.documents:before { background: #748b75 }
.source-tag.github:before { background: #687482 }
.assistant .bubble { white-space: normal }
.assistant .bubble>:first-child { margin-top: 0 }
.assistant .bubble>:last-child { margin-bottom: 0 }
.assistant .bubble p { margin: 0 0 12px }
.assistant .bubble h1,.assistant .bubble h2,.assistant .bubble h3 { margin: 20px 0 9px; color: var(--text); font-size: 13px; font-weight: 650 }
.assistant .bubble ul,.assistant .bubble ol { margin: 8px 0 14px; padding-left: 21px }
.assistant .bubble li { margin: 7px 0 }
.assistant .bubble li::marker { color: var(--accent) }
.assistant .bubble strong { color: var(--text) }
.assistant .bubble code { padding: 2px 5px; border-radius: 5px; color: #36513f; background: var(--accent-soft); font-size: .88em }
.assistant .bubble pre { max-width: 100%; padding: 14px; overflow-x: auto; border-radius: 10px; color: #e8ece8; background: #292d29 }
.assistant .bubble pre code { padding: 0; color: inherit; background: transparent }
.assistant .bubble a { color: #365d45; font-weight: 600; text-underline-offset: 3px }
.message.error .bubble { color: var(--danger); border-color: #ebcdcd; background: #fff7f7 }
.activity { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px }
.activity span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite }

.composer-wrap { padding: 0 clamp(20px,4vw,52px) 20px }

.composer {
  padding: 7px 7px 7px 17px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(32,35,31,.07);
  transition: border-color .18s ease,box-shadow .18s ease
}

.composer:focus-within { border-color: #9ba99d; box-shadow: 0 0 0 4px rgba(66,92,75,.07),0 8px 24px rgba(32,35,31,.06) }

textarea {
  width: 100%;
  max-height: 150px;
  min-height: 42px;
  padding: 10px 0;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 13px
}

textarea::placeholder { color: var(--subtle) }

.send {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--text);
  cursor: pointer;
  font-size: 18px;
  transition: opacity .18s ease,transform .18s ease
}

.send:hover { opacity: .86; transform: translateY(-1px) }
.send:active { transform: scale(.96) }
.send:disabled { opacity: .35; cursor: not-allowed; transform: none }
.composer-meta { margin: 9px 3px 0; display: flex; gap: 14px; color: var(--subtle); font-size: 9px }
.model-label { margin-left: auto; color: #aaada6 }

@keyframes enter { from { opacity: 0; transform: translateY(6px) } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8) } }

@media(max-width:900px) {
.shell { padding: 0; grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); gap: 0 }
.identity-rail {
  min-height: 68px;
  padding: max(12px,env(safe-area-inset-top)) max(15px,env(safe-area-inset-right)) 12px max(15px,env(safe-area-inset-left));
  flex-direction: row;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none
}
.rail-intro,.knowledge-panel { display: none }
.rail-footer { margin: 0 0 0 auto; padding: 0; border: 0 }
.rail-footer small { display: none }
.chat { border: 0; border-radius: 0; box-shadow: none }
}

@media(max-width:620px) {
.chat-header { display: none }
.identity-rail { min-height: 60px }
.mark { width: 38px; height: 38px; border-radius: 11px }
.brand small { display: none }
.rail-footer { gap: 7px }
.messages { padding: 22px 12px 120px }
.welcome { min-height: 0; align-content: center }
.orb { width: 64px; height: 64px; margin-bottom: 19px; border-radius: 19px }
.welcome h2 { font-size: clamp(29px,9vw,38px) }
.welcome>p:not(.welcome-label) { font-size: 13px }
.suggestions { margin-top: 24px; grid-template-columns: 1fr }
.suggestions button { min-height: 48px; font-size: 11px }
.message { gap: 8px; margin-bottom: 18px }
.message-content { max-width: 92% }
.assistant .message-content { max-width: calc(100% - 39px) }
.avatar { flex-basis: 30px; width: 30px; height: 30px }
.bubble { padding: 12px 13px; font-size: 14px; line-height: 1.6 }
.composer-wrap {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: var(--keyboard-offset,0px);
  left: 0;
  padding: 0 max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  background: linear-gradient(to bottom,rgba(243,243,239,0),var(--bg) 18px)
}
.composer { padding-left: 14px }
textarea { font-size: 16px }
.send { flex-basis: 44px; width: 44px; height: 44px }
.composer-meta span:not(.model-label) { display: none }
.model-label { width: 100%; margin-left: 0; text-align: center }
}

@media(prefers-reduced-motion:reduce) {
* { scroll-behavior: auto!important; animation: none!important }
}
