:root {
  color-scheme: light;
  font:
    15px/1.55 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  color: #24302e;
  background: #f7f8f6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
[hidden] {
  display: none !important;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  min-height: 42px;
  padding: 0.5rem 0.85rem;
  color: inherit;
  background: #fff;
  border: 1px solid #d8dfdb;
  border-radius: 8px;
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: #207665;
  background: #f1f7f3;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  color: white;
  background: #236d59;
  border-color: #236d59;
}
button.primary:hover:not(:disabled) {
  background: #18533f;
}
input,
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccd6cf;
  border-radius: 8px;
  color: inherit;
  background: #fff;
}
input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: 2px solid #48977d;
  outline-offset: 2px;
}
label,
small {
  color: #64726b;
  font-size: 0.82rem;
}
label {
  display: block;
  margin-bottom: 0.35rem;
}
h1,
p {
  margin: 0;
}
.login {
  height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 1.5rem;
}
.loginCard {
  margin-block: auto;
  flex-shrink: 0;
  display: grid;
  gap: 1rem;
  width: min(100%, 390px);
  padding: 2rem;
  background: white;
  border: 1px solid #e0e5df;
  border-radius: 16px;
}
.loginCard h1 {
  font-size: 1.8rem;
  letter-spacing: -0.06rem;
}
.loginCard p {
  color: #64726b;
  font-size: 0.9rem;
}
.loginCard #loginError {
  color: #a43c30;
}
.eyebrow {
  color: #236d59;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  font-weight: 700;
}
dialog {
  width: min(450px, calc(100% - 32px));
  max-height: 90dvh;
  padding: 0;
  border: 1px solid #d8dfdb;
  border-radius: 12px;
  overflow-y: auto;
}
dialog::backdrop {
  background: #14231d70;
}
dialog > header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e0e5df;
}
dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}
.settingsSection {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}
.settingsSection h3 {
  margin: 0;
  font-size: 1rem;
}
.settingsSection input {
  margin-top: 0.4rem;
}
#accountError,
#modelError {
  color: #a43c30;
  font-size: 0.85rem;
}
.sidebar footer .row {
  margin: 0;
}
.app {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  height: var(--app-height, 100dvh);
  width: 100%;
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  padding: 1.2rem;
  background: #eef1ec;
  border-right: 1px solid #dfe5dc;
}
.sidebar header,
.row,
.chatTop,
.titleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.status {
  font-size: 0.72rem;
  white-space: nowrap;
  color: #64726b;
}
.sidebar .row {
  margin-top: 0.6rem;
}
.sidebar .row .primary {
  flex: 1;
}
.sidebar nav {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.thread {
  width: 100%;
  margin-bottom: 0.4rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-color: transparent;
  background: transparent;
}
.thread strong,
.thread small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}
.thread strong {
  font-weight: 550;
}
.thread small {
  margin-top: 0.2rem;
  font-size: 0.7rem;
}
.thread.selected {
  background: white;
  border-color: #d3dfd4;
}
.sidebar footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
main {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'header' 'notice' 'messages' 'requests' 'composer';
  background: #fff;
}
.chatHeader {
  grid-area: header;
}
#notice {
  grid-area: notice;
}
.messages {
  grid-area: messages;
}
.requests {
  grid-area: requests;
}
.composer {
  grid-area: composer;
}
.chatHeader {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #e8ece7;
}
.chatTitle {
  flex: 1;
  min-width: 0;
}
.titleRow {
  justify-content: flex-start;
  gap: 0.5rem;
}
.titleRow h1 {
  flex: 1;
}
.titleRow .status {
  flex-shrink: 0;
  font-size: 0.7rem;
}
.modeBadge {
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: #e5f2e8;
  color: #236d59;
  font-size: 0.65rem;
  white-space: nowrap;
}
.statusBar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  margin-top: 0.7rem;
}
.statusChip {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  padding: 0.35rem 0.6rem;
  text-align: left;
  background: #f7f9f6;
  border-color: #e5ebe3;
  font-size: 0.78rem;
}
.statusChip small {
  flex-shrink: 0;
  font-size: 0.67rem;
}
.statusChip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contextChip {
  position: relative;
  padding-bottom: 0.45rem;
}
.contextChip meter {
  position: absolute;
  bottom: 1px;
  left: 5%;
  width: 90%;
  height: 4px;
}
.mobileOnly,
.sidebarBackdrop {
  display: none;
}
.sessionDetails {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem 1rem;
  margin: 0;
  font-size: 0.85rem;
}
.sessionDetails dt {
  color: #758078;
}
.sessionDetails dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.chatHeader > div {
  min-width: 0;
}
.chatHeader h1 {
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chatHeader p {
  margin-top: 0.25rem;
  color: #758078;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chatHeader button {
  flex-shrink: 0;
  font-size: 0.8rem;
}
#notice {
  padding: 0.75rem 1.5rem;
  color: #8a392a;
  background: #fff1e9;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.messages {
  padding: 1.5rem max(1.25rem, calc((100% - 820px) / 2));
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}
.empty {
  color: #8a938b;
  text-align: center;
  padding: 3rem 1rem;
}
.item {
  margin: 0 0 1.35rem;
}
.item > header {
  margin-bottom: 0.35rem;
  color: #7b857d;
  font-size: 0.72rem;
}
.item pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}
.item[data-type='userMessage'] {
  padding: 0.9rem 1rem;
  background: #f1f5ef;
  border-radius: 10px;
}
.item[data-type='commandExecution'] pre,
.item[data-type='fileChange'] pre {
  padding: 0.85rem;
  background: #f5f6f4;
  border: 1px solid #e4e8e2;
  border-radius: 8px;
  font:
    12px/1.65 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  max-height: 24rem;
  overflow: auto;
}
.item[data-type='reasoning'] {
  color: #778278;
  font-size: 0.85rem;
}
.requests {
  padding: 0 1.25rem;
  max-height: 40dvh;
  overflow-y: auto;
}
.request {
  margin: 0.5rem auto;
  padding: 1rem;
  border: 1px solid #d9b664;
  background: #fffcf1;
  border-radius: 10px;
  max-width: 820px;
}
.request > strong {
  display: block;
  margin-bottom: 0.75rem;
}
.request pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  max-height: 12rem;
  overflow: auto;
}
.request label {
  margin: 0.7rem 0;
}
.request input,
.request select {
  margin-top: 0.4rem;
}
.request button {
  margin-right: 0.5rem;
}
.attention {
  color: #7c5a16;
  border-color: #d9b664;
  background: #fffcf1;
  font-size: 0.8rem;
}
.composer {
  position: relative;
  min-width: 0;
  padding: 1rem max(1.25rem, calc((100% - 820px) / 2))
    calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid #e8ece7;
}
.composer textarea {
  resize: none;
  min-height: 78px;
  max-height: 220px;
}
.composer .row {
  margin-top: 0.5rem;
}
.composer small {
  font-size: 0.72rem;
}
.composerTools {
  justify-content: flex-start;
}
.composerTools > small {
  flex: 1;
  min-width: 0;
}
.composerTools > button {
  flex-shrink: 0;
}
.commandMenu {
  position: absolute;
  z-index: 20;
  left: 1rem;
  right: 1rem;
  bottom: calc(100% + 0.4rem);
  max-height: min(calc(var(--app-height, 100dvh) * 0.42), 330px);
  overflow-y: auto;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid #cbd7cc;
  border-radius: 10px;
  box-shadow: 0 8px 28px #19321d26;
}
.commandOption {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border-color: transparent;
  text-align: left;
}
.commandOption code {
  color: #236d59;
  font-size: 0.85rem;
}
.commandOption small {
  font-size: 0.75rem;
}
.commandOption.selected {
  background: #edf5ee;
  border-color: #bcd0be;
}
.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .mobileOnly {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .sidebarBackdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: #14231d70;
  }
  .app.sidebarOpen .sidebar {
    transform: translateX(0);
  }
  input,
  textarea,
  select {
    font-size: 16px;
  }
  .login {
    padding: 1rem;
  }
  .loginCard {
    padding: 1.5rem;
  }
  dialog {
    width: calc(100% - 20px);
    max-height: calc(var(--app-height, 100dvh) - 24px);
  }
  dialog > header,
  .settingsSection {
    padding: 1rem;
  }
  main {
    grid-column: 1;
  }
  .chatTop {
    gap: 0.5rem;
  }
  .chatTop > button {
    min-height: 40px;
    padding: 0.45rem 0.55rem;
    font-size: 0.78rem;
  }
  .statusBar {
    gap: 0.3rem;
    margin-top: 0.5rem;
  }
  .statusChip {
    gap: 0.3rem;
    padding-inline: 0.4rem;
    font-size: 0.75rem;
  }
  .statusChip small {
    font-size: 0.62rem;
  }
  .titleRow .status {
    font-size: 0.6rem;
  }
  .chatHeader h1 {
    font-size: 0.9rem;
  }
  .chatHeader p {
    font-size: 0.65rem;
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, 340px);
    height: var(--app-height, 100dvh);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    padding: max(1rem, env(safe-area-inset-top)) 1rem
      max(1rem, env(safe-area-inset-bottom));
    gap: 0.9rem;
    border-right: 1px solid #dfe5dc;
  }
  .chatHeader {
    padding: max(0.65rem, env(safe-area-inset-top)) 0.75rem 0.6rem;
  }
  .messages {
    padding: 1rem;
  }
  .composer {
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
  }
  .composer textarea {
    min-height: 66px;
    max-height: min(calc(var(--app-height, 100dvh) * 0.25), 180px);
  }
  .composerTools {
    gap: 0.4rem;
  }
  .composerTools > button {
    min-height: 40px;
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }
  .composerTools > small {
    font-size: 0.62rem;
  }
  .requests {
    max-height: calc(var(--app-height, 100dvh) * 0.32);
    padding-inline: 0.75rem;
  }
  .request {
    padding: 0.8rem;
  }
  .request button {
    margin-top: 0.35rem;
  }
  .commandMenu {
    left: 0.5rem;
    right: 0.5rem;
  }
  .empty {
    padding: 2rem 0.5rem;
    font-size: 0.85rem;
  }
}
