/* One navigation surface. Dock panels only when the conversation has room to breathe. */
.app {
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr);
  grid-template-rows: calc(64px + env(safe-area-inset-top)) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.app.sidebar-open {
  grid-template-columns: 248px minmax(0, 1fr);
}
.chat-topbar {
  grid-area: 1 / 2;
  min-width: 0;
  height: auto;
  padding: env(safe-area-inset-top) 20px 0;
  gap: 12px;
  border: 0;
  background: var(--bg);
  backdrop-filter: none;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.sidebar-icon .icon {
  transform: scaleX(-1);
}
.conversation-heading {
  min-width: 0;
}
.conversation-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  min-width: 0;
}
.conversation-heading h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 450;
  color: var(--text-3);
}
.conversation-meta {
  color: var(--warn);
  font-size: 11px;
}
.conversation-meta:empty {
  display: none;
}
.workspace-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: max(36px, var(--target));
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  font-size: 12px;
  color: var(--text-2);
}
.workspace-toggle:active:not(:disabled),
.starters button:active:not(:disabled),
.sidebar-action:active:not(:disabled) {
  background: var(--bg-active);
}
.workspace-toggle:disabled {
  color: var(--text-3);
  opacity: 0.6;
}
.workspace-toggle .icon {
  width: 15px;
  height: 15px;
}
.workspace-toggle:hover:not(:disabled),
.workspace-toggle[aria-expanded="true"] {
  background: var(--bg-hover);
  color: var(--text);
}
.ellipsis {
  font-size: 24px;
  line-height: 1;
  letter-spacing: 1px;
  margin-top: -9px;
}
.chat-sidebar {
  grid-area: 1 / 1 / 3 / 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.sidebar-open .chat-sidebar {
  visibility: visible;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 64px;
  flex: none;
  padding: 0 12px 0 20px;
}
.sidebar-head .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.4px;
}
.sidebar-head .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 23px;
  background: transparent;
  color: var(--accent);
}
.brand-detail {
  font-size: 11px;
  font-weight: 450;
  letter-spacing: 0;
  color: var(--text-3);
  margin-left: -4px;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 42px;
  margin: 10px 14px 18px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  text-align: left;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
}
.sidebar-action .icon {
  width: 17px;
  height: 17px;
  color: var(--accent);
}
.sidebar-action:hover {
  background: var(--bg-hover);
}
.sidebar-action:disabled {
  opacity: 0.45;
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 10px 20px;
}
.chat-group + .chat-group {
  margin-top: 20px;
}
.chat-group h2 {
  margin: 6px 12px 9px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 550;
}
.chat-list {
  display: grid;
  gap: 2px;
}
.chat-list a,
.chat-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  text-align: left;
}
.chat-list a:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.chat-list [aria-current="page"] {
  background: var(--bg-active);
  color: var(--text);
}
.chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-status {
  padding: 12px;
  color: var(--text-3);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.sidebar-status:empty {
  display: none;
}
.sidebar-foot {
  flex: none;
  padding: 8px 10px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.account-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
}
.account-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  font:
    600 23px/1 Georgia,
    serif;
}
.account-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-copy span:first-child {
  font-size: 12px;
  font-weight: 550;
}
.panel-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  border: 0;
  background: rgb(0 0 0 / 0.48);
  animation: veil-in 160ms ease-out;
}
.workspace {
  grid-area: 2 / 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.workspace.files-open {
  grid-template-columns: minmax(0, 1fr) 320px;
}
.conversation {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.conversation #messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 32px 18px;
  scrollbar-gutter: stable both-edges;
}
.conversation #messages > * {
  max-width: var(--column);
  margin-inline: auto;
}
.conversation #messages > .empty {
  display: none;
}
.conversation #messages:focus-visible {
  outline-offset: -2px;
}
.composer-dock {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 75%;
  overflow: hidden;
  padding: 8px 32px max(24px, env(safe-area-inset-bottom));
}
.composer-dock > * {
  width: 100%;
  max-width: var(--column);
  margin-inline: auto;
}
.composer-context {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.composer-dock > #prompt-form {
  flex-shrink: 0;
}
.conversation[data-empty="true"] {
  justify-content: center;
}
.conversation[data-empty="true"] #messages {
  display: none;
}
.conversation[data-empty="true"] .composer-dock {
  max-height: 100%;
  padding-top: 36px;
  padding-bottom: max(64px, env(safe-area-inset-bottom));
}
.welcome {
  text-align: center;
  margin-bottom: 30px;
}
.welcome-mark {
  margin: 0 auto 24px;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 32px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.welcome h2 {
  margin: 10px 0;
  color: var(--text);
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.2;
  font-weight: 550;
  letter-spacing: -1.25px;
  text-wrap: balance;
}
.welcome-description {
  color: var(--text-2);
  font-size: 14px;
}
.starters {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 18px;
}
.starters button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: max(36px, var(--target));
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--bg-subtle);
  color: var(--text-2);
  font-size: 12px;
  transition:
    background 150ms,
    border-color 150ms;
}
.starters .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}
.starters button:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
  color: var(--text);
}
.run-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0 8px 10px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}
.run-status:has(#status:empty) {
  display: none;
}
.run-status .dot,
.run-status .spinner {
  margin-top: 4px;
}
.run-status p {
  flex: 1;
  min-width: 0;
}
.app[data-busy="true"] .run-status {
  color: var(--text-2);
}
.app[data-tone="warn"] .run-status {
  color: var(--warn);
}
.app[data-tone="danger"] .run-status {
  color: var(--danger);
}
.composer {
  container-type: inline-size;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--composer);
  padding: 18px 12px 10px 20px;
  box-shadow:
    0 4px 20px rgb(0 0 0 / 0.04),
    0 1px 2px rgb(0 0 0 / 0.03);
  transition:
    border-color 150ms,
    box-shadow 150ms;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line-strong));
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 6%, transparent),
    0 4px 20px rgb(0 0 0 / 0.04);
}
#prompt {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 40dvh;
  padding: 0 4px 0 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
#prompt[readonly] {
  color: var(--text-2);
}
#prompt::placeholder {
  color: var(--text-3);
  opacity: 1;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  min-width: 0;
}
.composer-bar .spacer {
  flex: 1;
}
.composer-plus {
  flex: none;
  color: var(--text-2);
  border-radius: 50%;
}
.model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 60%;
  min-height: max(32px, var(--target));
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 450;
}
.model-trigger:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.model-trigger .model-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-trigger .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}
.model-trigger[data-tone="danger"] {
  color: var(--danger);
}
.header-model {
  max-width: 100%;
  min-height: max(28px, var(--target));
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}
.kbd-hint {
  min-height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  white-space: nowrap;
}
.kbd-hint:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.kbd-hint kbd {
  font: 10px var(--font);
}
.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: max(40px, var(--target));
  height: max(40px, var(--target));
  padding: 0;
  border: 0;
  border-radius: 50px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 12px;
  font-weight: 550;
  transition:
    opacity 150ms,
    background-color 150ms;
}
.send:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 85%, var(--bg));
}
.send:disabled {
  background: var(--bg-active);
  color: var(--text-3);
}
.send:active:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 80%, var(--text));
}
.send .send-label:empty {
  display: none;
}
.send .send-label:not(:empty) {
  padding-right: 12px;
}
.send:has(.send-label:not(:empty)) {
  padding-left: 10px;
}
.stop {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line-strong));
}
.stop .icon svg {
  fill: currentColor;
}
.jump {
  position: absolute;
  z-index: 5;
  bottom: calc(var(--composer-height, 120px) + 10px);
  left: 50%;
  translate: -50% 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  color: var(--text);
}
.jump:hover:not(:disabled) {
  background: var(--bg-raised);
}
.conversation[data-empty="true"] .jump {
  display: none;
}
.app .side-panel {
  background: var(--sidebar);
}
.app .panel-head {
  height: 56px;
  padding: 0 14px 0 20px;
  gap: 4px;
}
.app .panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.app .panel-head h2 .icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}
.app .panel-body {
  padding: 16px 12px 24px;
}
.app .panel-section {
  padding: 20px 8px;
}
.app .panel-section:first-child {
  padding-top: 0;
}
.app .panel-section h3 {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
}
.app .panel-status {
  margin-inline: 0;
  font-size: 12.5px;
  line-height: 1.55;
}
.files-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 18px 0;
  padding: 24px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
}
.files-empty > .icon {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  color: var(--text-3);
}
.files-empty strong {
  font-size: 14px;
  font-weight: 550;
}
.files-empty p {
  font-size: 12.5px;
  color: var(--text-3);
}
.app .workspace-state {
  font-size: 13px;
}
.app .workspace-state .hint {
  font-size: 12px;
  margin-top: 4px;
}
.app .panel-section > .hint {
  margin-top: 12px;
  font-size: 12.5px;
}
#process-list {
  font-size: 12px;
  color: var(--text-3);
}
.app .panel-section details > summary {
  font-size: 13px;
}
.app .panel-section details > .button {
  margin-top: 10px;
}
.app .panel-section details p {
  font-size: 12.5px;
  line-height: 1.55;
}
#force-stop {
  margin-top: 16px;
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}
#force-stop:disabled {
  border-color: var(--line);
}
.account-actions {
  right: 16px;
  top: calc(64px + env(safe-area-inset-top));
}
.chat-actions {
  top: calc(58px + env(safe-area-inset-top));
  right: 20px;
}
.device-card {
  width: min(100%, 400px);
}
.device-eyebrow {
  margin: 24px 0 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.device-copy {
  width: 100%;
  margin-top: 8px;
}
.device-back {
  display: block;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
  text-underline-offset: 4px;
}
@media (pointer: coarse) {
  .chat-list a,
  .sidebar-action {
    min-height: 44px;
  }
  .send {
    min-width: 44px;
  }
  .kbd-hint {
    display: none;
  }
}
@container (max-width: 600px) {
  .kbd-hint {
    display: none;
  }
}
@container (max-width: 450px) {
  .send .send-label,
  .composer-bar .stop .button-label {
    display: none;
  }
  .send:has(.send-label:not(:empty)) {
    padding-left: 0;
  }
  .composer-bar .stop {
    width: var(--target);
    padding: 0;
    flex: none;
  }
  .composer-bar .model-trigger {
    flex: 1;
    justify-content: flex-end;
    max-width: none;
    padding-inline: 4px;
  }
  .composer-bar .spacer {
    display: none;
  }
}
@media (max-width: 1279px) {
  .workspace.files-open {
    grid-template-columns: minmax(0, 1fr);
  }
  .app .side-panel {
    position: fixed;
    z-index: 50;
    inset: 12px 12px 12px auto;
    width: min(380px, calc(100% - 24px));
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: var(--shadow-pop);
    animation: panel-in 180ms ease-out;
  }
}
@media (max-width: 1023px) {
  .app,
  .app.sidebar-open {
    grid-template-columns: 0 minmax(0, 1fr);
  }
  .chat-sidebar {
    position: fixed;
    z-index: 50;
    inset: 12px auto 12px 12px;
    width: min(288px, calc(100% - 48px));
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-pop);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar-open .chat-sidebar {
    animation: panel-in 180ms ease-out;
  }
  .chat-topbar {
    padding-inline: 16px;
  }
}
@media (max-width: 640px) {
  .app {
    grid-template-rows: calc(60px + env(safe-area-inset-top)) minmax(0, 1fr);
  }
  .chat-topbar {
    gap: 4px;
    padding-inline: 8px;
  }
  .header-nav [data-new-chat] {
    display: none;
  }
  .chat-topbar .icon-button {
    width: max(40px, var(--target));
    height: max(40px, var(--target));
  }
  .conversation-heading {
    flex: 1;
  }
  .chat-topbar > .spacer {
    flex: 0;
  }
  .conversation-meta {
    display: none;
  }
  .conversation-subtitle {
    padding-left: 6px;
    line-height: 1.2;
  }
  .header-model {
    padding-inline: 6px;
    font-size: 13px;
  }
  .workspace-toggle {
    width: max(40px, var(--target));
    height: max(40px, var(--target));
    padding: 0;
    border: 0;
  }
  .workspace-toggle .button-label {
    display: none;
  }
  .workspace-toggle .icon {
    width: 18px;
    height: 18px;
  }
  .conversation #messages {
    padding: 20px 16px 12px;
    scrollbar-gutter: auto;
  }
  .composer-dock {
    padding: 6px 14px max(16px, env(safe-area-inset-bottom));
  }
  .conversation[data-empty="true"] .composer-dock {
    padding-top: 24px;
    padding-bottom: 40px;
  }
  .welcome {
    margin-bottom: 24px;
  }
  .welcome-mark {
    margin-bottom: 20px;
  }
  .welcome h2 {
    letter-spacing: -0.8px;
  }
  .welcome-description {
    font-size: 13px;
  }
  .composer {
    padding: 16px 10px 10px 16px;
    border-radius: 18px;
  }
  #prompt {
    font-size: 16px;
  }
  .composer-bar {
    gap: 4px;
    margin-top: 10px;
  }
  .starters {
    gap: 6px;
    padding-top: 16px;
  }
  .starters button {
    font-size: 12px;
    padding-inline: 10px;
  }
  .starters .icon {
    width: 12px;
    height: 12px;
  }
  .app .side-panel {
    inset: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
  }
  .app .panel-head {
    height: 60px;
  }
  .chat-actions,
  .account-actions {
    top: calc(58px + env(safe-area-inset-top));
    right: 12px;
  }
}
@media (max-height: 580px) {
  .conversation[data-empty="true"] .composer-dock {
    padding-block: 20px;
  }
  .welcome-mark {
    display: none;
  }
  .welcome {
    margin-bottom: 20px;
  }
  .starters {
    padding-top: 12px;
  }
}
/* macOS title-bar traffic lights reserve space without shifting conversation baselines. */
html[data-client="mac"] .chat-topbar {
  padding-left: 88px;
}
html[data-client="mac"] .sidebar-open .chat-topbar {
  padding-left: 20px;
}
html[data-client="mac"] .sidebar-head {
  padding-top: 26px;
  height: 82px;
}
@media (max-width: 1023px) {
  html[data-client="mac"] .sidebar-open .chat-topbar {
    padding-left: 88px;
  }
}
@keyframes panel-in {
  from {
    opacity: 0;
    translate: 0 6px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes veil-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .panel-backdrop,
  .chat-sidebar,
  .app .side-panel {
    animation: none;
  }
}
