:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f7f7f4;
  --panel-2: #f1f1ee;
  --text: #171717;
  --muted: #6f6f67;
  --line: #e5e5df;
  --accent: #10a37f;
  --user: #2f2f2f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
  background: var(--bg);
  color: var(--text);
}

button, textarea, select, input { font: inherit; }

.sidebar {
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow: auto;
}

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

.mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: white;
  font-weight: 800;
}

.brand span, .project-heading span, .hint, .side-title, .provider {
  color: var(--muted);
  font-size: 12px;
}

.new-chat, .project, .ghost, .icon-btn, .tool-row button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.new-chat {
  width: 100%;
  height: 42px;
  text-align: left;
  padding: 0 12px;
  font-weight: 650;
}

.side-title {
  margin: 22px 4px 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}

.project-list, .provider-list, .material-list {
  display: grid;
  gap: 6px;
}

.project-tools {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.project-tools input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  outline: none;
}

.project-tools input:focus {
  border-color: var(--accent);
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tool-row button {
  height: 36px;
  font-size: 12px;
  font-weight: 650;
}

.project {
  min-height: 64px;
  padding: 10px;
  text-align: left;
}

.project.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.project strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.project span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.provider {
  padding: 7px 4px;
  display: grid;
  gap: 4px;
}

.provider strong {
  color: var(--muted);
  font-size: 12px;
}

.provider small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-line;
}

.material {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  padding: 9px 10px;
  text-decoration: none;
}

.material span {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.main {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr auto;
}

.topbar {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
}

.project-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.project-heading strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

select, .ghost, .icon-btn {
  height: 36px;
  padding: 0 10px;
}

.messages {
  overflow: auto;
  padding: 28px 18px 24px;
}

.message {
  max-width: 820px;
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  font-weight: 800;
}

.message.user .avatar {
  background: var(--user);
  color: white;
}

.bubble {
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble a {
  color: #0f766e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bubble strong {
  display: block;
  margin-bottom: 4px;
}

.agent-message {
  margin-top: -12px;
}

.agent-trace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  padding: 10px 12px;
  font-size: 13px;
}

.agent-row {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.agent-row:first-of-type {
  border-top: 0;
}

.agent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.agent-head span {
  font-weight: 700;
}

.agent-head em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.agent-row p {
  margin: 5px 0 0;
  color: #3f3f3a;
  line-height: 1.45;
  white-space: pre-wrap;
}

.composer-wrap {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.composer {
  max-width: 820px;
  margin: 0 auto;
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr 42px 42px 42px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  padding: 8px;
}

textarea {
  border: 0;
  resize: none;
  outline: none;
  padding: 8px 6px;
  min-height: 36px;
  max-height: 160px;
  line-height: 1.45;
}

#sendBtn, #voiceBtn, #fileBtn {
  width: 42px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#sendBtn {
  color: white;
  background: var(--text);
  font-size: 20px;
}

#voiceBtn, #fileBtn {
  color: var(--text);
  background: var(--panel-2);
  font-size: 18px;
}

#voiceBtn.recording {
  color: white;
  background: var(--accent);
}

.hint {
  max-width: 820px;
  margin: 8px auto 0;
}

.mobile-only { display: none; }

@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 86vw;
    max-width: 330px;
    transform: translateX(-104%);
    transition: transform .18s ease;
    z-index: 10;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { padding: 0 12px; }
  .top-actions .ghost { display: none; }
  .messages { padding-inline: 12px; }
}
