
:root {
  /* light theme */
  --bg: #ffffff;
  --panel: #f6f7fb;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0a58ca;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --sidebar: 290px;
  --radius: 14px;

  /* composer placement (raised) */
  --composer-offset: 220px;
  --composer-min-h: 140px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
}

a {
  color: var(--ink);
  text-decoration: none;
}

svg {
  display: block;
}

/* layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  height: 100vh; /* panes scroll independently */
}

/* sidebar */
.side {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand .name {
  font-weight: 700;
  letter-spacing: .2px;
}

.side .btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.side .btn:hover {
  border-color: #c7cedb;
}

.search {
  display: flex;
  gap: 8px;
}

.search input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.lib {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: #fff;
}

.section-title {
  margin: 6px 6px 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* Only the chats list scrolls when it overflows */
.chats {
  flex: 1;
  overflow: auto; /* independent scroll */
  min-height: 0;
  padding-right: 6px;
}

.chat-item {
  padding: 10px 12px;
  border-radius: 10px;
  margin: 6px 0;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.chat-item.active {
  border-color: var(--brand);
  background: #eef3ff;
}

.footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.api {
  margin-top: 6px;
  font-size: 12px;
}

.api.ok {
  color: var(--ok);
}

.api.warn {
  color: var(--warn);
}

.api.bad {
  color: var(--danger);
}

/* main */
.main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* messages */
.messages {
  flex: 1;
  background: var(--bg);
  overflow: auto;
  padding: 18px;
  min-height: 0;
  height: calc(100vh - var(--composer-offset) - 24px);
  padding-bottom: 24px;
  overscroll-behavior: contain;
}

/* bubbles */
.bubble {
  max-width: 820px;
  padding: 12px 14px;
  border-radius: 14px;
  margin: 10px 0;
  background: #fff;
  white-space: pre-wrap;
  border: none;
}

.bubble.me {
  background: #f2f6ff;
}

.bubble.thinking {
  font-style: italic;
  opacity: 0.75;
}

/* composer */
.composer {
  position: fixed;
  left: var(--sidebar);
  right: 0;
  bottom: var(--composer-offset);
  padding: 0 18px;
  z-index: 1000;
}

.composer .box {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.composer textarea {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  resize: vertical;
  min-height: var(--composer-min-h);
  max-height: 50vh;
  line-height: 1.4;
  font-family: inherit;
  font-size: 14px;
}

.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin-top: 2px;
}

.iconbtn:hover {
  border-color: #c7cedb;
}

.mode-group {
  display: flex;
  gap: 6px;
  margin: 2px 6px 0 0;
}

.pill {
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  color: #6b7280;
  background: #fff;
  cursor: pointer;
  position: relative;
}

.pill.active {
  border-color: var(--brand);
  color: #0a58ca;
  background: #eef3ff;
}

.hidden {
  display: none;
}

/* tooltips */
.tip {
  position: relative;
}

.tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 8px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: .12s ease;
  border: 1px solid #00000020;
}

.tip:hover::after {
  opacity: 1;
}

/* scrim */
.composer-scrim {
  position: fixed;
  left: var(--sidebar);
  right: 0;
  bottom: 0;
  height: calc(var(--composer-offset));
  background: var(--bg);
  pointer-events: none;
  z-index: 950;
}

@media (max-width: 950px) {
  .app {
    grid-template-columns: 1fr;
  }

  .composer {
    left: 0;
  }

  .composer-scrim {
    left: 0;
  }

  .side {
    display: none;
  }
}

/* utility classes */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.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;
}

/* bubbles wrapping */
.messages .bubble,
.messages .bubble p {
  white-space: pre-wrap;
}

.messages .bubble * {
  white-space: inherit;
}

.messages .bubble {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.messages .bubble .meta.time {
  display: none !important;
}

/* Allow copy/select in chat */
.messages, .messages * {
  user-select: text !important;
  -webkit-user-select: text !important;
  -ms-user-select: text !important;
}

/* Enable text selection / copy inside the chat */
.messages, .messages * {
  user-select: text !important;
  -webkit-user-select: text !important;
  -ms-user-select: text !important;
}
  /* --- Chat selection + overlay fix --- */
.messages, .messages * {
  user-select: text !important;
  -webkit-user-select: text !important;
  -ms-user-select: text !important;
  -moz-user-select: text !important;
}
.messages { pointer-events: auto !important; }

/* The scrim was intercepting drags — disable its hitbox */
.composer-scrim {
  pointer-events: none !important;
  background: transparent !important;
  height: 0 !important;
  opacity: 0 !important;
}
