.larry-chat-toggle {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 80;
  min-width: 4.6rem;
  min-height: 2.8rem;
  border-radius: 999px;
  box-shadow: 0 10px 32px rgb(15 23 42 / 22%);
}

.larry-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  width: 31rem;
  max-width: 100vw;
  background: var(--surface-1, #181825);
  color: var(--fg, #cdd6f4);
  border-left: 1px solid var(--line, #313244);
  box-shadow: -16px 0 42px rgb(15 23 42 / 18%);
}
.larry-chat-panel > * {
  min-width: 0;
}

.larry-chat-panel[hidden] { display: none; }
.larry-chat-head,
.larry-chat-sessionbar,
.larry-chat-inline-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.larry-chat-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.larry-chat-head {
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border, #d8dee8);
}

.larry-chat-head-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.larry-chat-head-actions {
  flex-shrink: 0;
  display: flex;
  gap: .25rem;
}

.larry-provider-pill {
  appearance: none;
  background: var(--surface-2, #1e1e2e);
  border: 1px solid var(--line, #313244);
  border-radius: 999px;
  padding: 0.15rem 1.4rem 0.15rem 0.6rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--fg, #cdd6f4);
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a6adc8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.3rem center;
}
.larry-provider-pill:hover {
  background-color: var(--surface-3, #252538);
}

.larry-chat-head-actions { display: flex; gap: .35rem; }
.larry-chat-status {
  display: block;
  color: var(--fg-muted, #a6adc8);
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.larry-chat-sessionbar {
  padding: .35rem .75rem;
  border-bottom: 1px solid var(--line, #313244);
}

.larry-chat-sessionbar select { min-width: 0; flex: 1; }
.larry-session-select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--fg);
  font-weight: 500;
  cursor: pointer;
  padding: 0.2rem 1rem 0.2rem 0;
  outline: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a6adc8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}
.larry-session-select:hover { color: var(--fg-strong, #fff); }
.larry-chat-modelbar {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr .8fr .9fr;
  gap: .4rem;
  padding: .5rem .75rem 0;
}
.larry-chat-modelbar label {
  min-width: 0;
  color: var(--fg-muted, #a6adc8);
  font-size: .68rem;
}
.larry-chat-modelbar select { width: 100%; min-width: 0; }
.larry-chat-provider-note {
  min-height: 1.1rem;
  margin: .2rem .75rem .35rem;
  color: var(--fg-muted, #a6adc8);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.larry-chat-events {
  overflow: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
}

.larry-event-user, .larry-event-assistant {
  padding: .65rem .95rem;
  border-radius: .75rem;
  line-height: 1.45;
  width: fit-content;
  max-width: 90%;
  word-wrap: break-word;
}
.larry-event-user pre, .larry-event-assistant pre {
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: rgba(0,0,0,0.2);
  padding: .5rem;
  border-radius: .25rem;
}
.larry-event-user code, .larry-event-assistant code {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.larry-h2, .larry-h3, .larry-h4 {
  margin-top: 0.6rem;
  margin-bottom: 0.3rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg-strong, #fff);
}
.larry-h2 { font-size: 1.1rem; border-bottom: 1px solid var(--line, #313244); padding-bottom: 0.2rem; }
.larry-h3 { font-size: 1.0rem; }
.larry-h4 { font-size: 0.92rem; }

.larry-ul {
  margin: 0.3rem 0;
  padding-left: 1.2rem;
  list-style-type: disc;
}
.larry-li {
  margin-bottom: 0.2rem;
}
.larry-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--surface-2, #1e1e2e);
  color: var(--accent-subtle, #89b4fa);
}
.larry-wikilink {
  color: var(--accent, #89b4fa);
  text-decoration: underline;
  font-weight: 500;
}
.larry-thinking-details {
  margin: 0.4rem 0;
  padding: 0.3rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line, #313244);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--fg-muted, #a6adc8);
}
.larry-thinking-summary {
  cursor: pointer;
  font-weight: 500;
  outline: none;
  user-select: none;
  padding: 0.2rem 0;
}
.larry-thinking-summary:hover {
  color: var(--fg-strong, #fff);
}
.larry-thinking-steps {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--line, #313244);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
}
.larry-thinking-step {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--fg-muted, #9399b2);
  word-break: break-all;
}


.larry-event-user {
  margin-left: auto;
  color: var(--on-accent, #fff);
  background: var(--accent, #3056d3);
}

.larry-event-assistant { background: var(--surface-3, #252538); }
.larry-event-error { color: #f38ba8; background: #311; }
.larry-event-tool,
.larry-event-context,
.larry-event-status {
  max-width: 100%;
  padding: .3rem 0;
  color: var(--fg-muted, #a6adc8);
  font-size: .78rem;
}

.larry-permission {
  max-width: 100%;
  border: 1px solid #d6a84b;
  background: #fff8e7;
}

.larry-permission pre {
  max-height: 12rem;
  overflow: auto;
  font: .75rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.larry-chat-form,
.larry-chat-transcript {
  padding: .75rem;
  border-top: 1px solid var(--line, #313244);
  background: var(--surface-1, #181825);
}

.larry-chat-form textarea,
.larry-chat-transcript textarea {
  width: 100%;
  resize: vertical;
}

.larry-chat-tools { margin-top: .5rem; flex-wrap: wrap; }
.larry-chat-send { margin-left: auto; }
.larry-file-label { cursor: pointer; }
.larry-file-label input { position: fixed; left: -9999px; }
.larry-chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: 0 .75rem;
}

.larry-attachment,
.larry-ref {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  max-width: 100%;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: var(--surface-2, #1e1e2e);
  font-size: .78rem;
}

.larry-chat-mention-box {
  margin-bottom: .5rem;
  padding: .5rem;
  border: 1px solid var(--line, #313244);
  border-radius: .5rem;
}

.larry-chat-mention-box input { width: 100%; }
.larry-chat-mention-results {
  display: grid;
  max-height: 12rem;
  overflow: auto;
  margin-top: .35rem;
}

.larry-mention-result {
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.larry-empty { color: var(--fg-muted, #a6adc8); text-align: center; }

body.larry-chat-open { overflow: hidden; }

@media (min-width: 62rem) {
  body.larry-chat-open .app-shell { margin-right: min(31rem, 100vw); }
  body.larry-chat-open { overflow: auto; }
}

@media (max-width: 40rem) {
  .larry-chat-panel { width: 100vw; }
  .larry-chat-toggle { right: .75rem; bottom: .75rem; }
  .larry-chat-sessionbar { flex-wrap: wrap; }
  .larry-chat-modelbar { grid-template-columns: 1fr 1fr; }
}
