.sign-in { width: min(380px, calc(100vw - 32px)); max-height: calc(var(--app-height, 100dvh) - 24px); overflow: auto; overscroll-behavior: contain; padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper); box-shadow: 0 16px 60px #11172d29; }
.sign-in::backdrop { background: #181e3438; }
.sign-card { position: relative; padding: 26px; }
.sign-card .sign-close { position: absolute; top: 8px; right: 8px; }
.sign-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.sign-brand img { width: 32px; height: 32px; }
.sign-heading { margin: 18px 0 16px; }
.sign-heading h2 { font-size: 22px; margin: 0 0 5px; font-weight: 600; }
.sign-heading h2:focus { outline: none; }
.sign-heading p { color: var(--muted); margin: 0; }
.model-menu input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); }
.error { color: var(--error); margin: 0; overflow-wrap: anywhere; }
.primary { padding: 10px 16px; margin-top: 6px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:disabled { opacity: .65; }

.app {
  --history-width: 244px;
  --sidebar-width: var(--history-width);
  --splitter-width: 9px;
  --preview-space: calc(100% - var(--sidebar-width) - var(--splitter-width));
  --preview-width: clamp(235px, calc(var(--preview-space) * var(--preview-ratio, .45)), calc(var(--preview-space) - 295px));
  display: grid;
  grid-template-columns: var(--history-width) minmax(0, 1fr);
  height: var(--app-height, 100dvh);
  overflow: hidden;
}
.app.with-preview { grid-template-columns: var(--history-width) minmax(0, 1fr) var(--splitter-width) var(--preview-width); }
.app.history-closed { --sidebar-width: 0px; grid-template-columns: minmax(0, 1fr); }
.app.history-closed.with-preview { grid-template-columns: minmax(0, 1fr) var(--splitter-width) var(--preview-width); }
.history-closed .sidebar { display: none; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
.brand-row, .account-row { display: flex; align-items: center; gap: 8px; min-width: 0; height: 40px; }
.brand-row { padding-inline: 8px 2px; }
.brand-row strong { flex: 1; font-size: 16px; font-weight: 550; }
.icon-button { display: grid; place-items: center; flex: none; width: 32px; height: 32px; color: var(--muted); border-radius: 7px; }
.icon-button:hover, .subtle:hover, .model-button:hover:not(:disabled), .new-chat:hover, .balance:hover, .history-item:hover, .model-option:hover { background: var(--hover); color: var(--ink); }
.new-chat { display: flex; align-items: center; width: 100%; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; text-align: left; font-weight: 500; }
.history-label { margin: 14px 10px 0; color: var(--muted); font-size: 13px; }
.history { flex: 1; min-height: 0; overflow: auto; padding: 2px; }
.history-item { display: flex; align-items: center; gap: 7px; text-align: left; width: 100%; padding: 8px; border-radius: 8px; }
.history-item[aria-current] { background: var(--hover); }
.history-item svg { color: var(--muted); }
.history-item span, .account-name, .topbar span, .balance span, .model-name, #model-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-history { color: var(--faint); padding: 6px 8px; margin: 0; font-size: 13px; }
.account { border-top: 1px solid var(--line); padding-top: 5px; }
.balance { display: inline-flex; align-items: center; justify-content: flex-end; flex: 0 1 auto; min-width: 0; max-width: 53%; min-height: 36px; padding: 0 6px; border-radius: 7px; color: var(--muted); font-size: 12px; }
.balance strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 550; }
.account-row { gap: 4px; height: auto; }
.account-name { flex: 1; }
.avatar { width: 25px; height: 25px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--hover); color: var(--muted); font-size: 13px; }

.conversation { display: grid; grid-template-rows: 54px minmax(0, 1fr); min-width: 0; min-height: 0; }
.conversation.has-thread { grid-template-rows: 54px minmax(0, 1fr) auto; }
.topbar { display: flex; align-items: center; min-width: 0; gap: 10px; padding: 9px 16px; }
.topbar span { min-width: 0; font-weight: 500; }
.app:not(.history-closed) #show-history { visibility: hidden; width: 0; padding: 0; margin-right: -10px; }
.subtle { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; border-radius: 7px; padding: 3px 7px; font-size: 13px; color: var(--muted); }
.subtle svg { width: 16px; height: 16px; }
.preview-toggle { margin-left: auto; flex: none; }
.thread { overflow: auto; scrollbar-width: thin; padding: 23px 25px 30px; }
.messages { width: min(100%, 760px); margin: 0 auto; display: flex; flex-direction: column; gap: 25px; }
.message { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; max-width: min(88%, 650px); border-radius: 14px; padding: 9px 15px; background: var(--bubble); white-space: pre-wrap; }
.message.assistant { display: grid; gap: 12px; font-size: 14px; line-height: 24px; }
.reply-content { display: grid; gap: 16px; min-width: 0; }
.markdown { min-width: 0; overflow-x: auto; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown :is(p, ul, ol, blockquote, pre) { margin: 0 0 12px; }
.markdown :is(h1, h2, h3, h4) { margin: 12px 0 8px; line-height: 1.45; }
.markdown h1 { font-size: 1.4em; }
.markdown h2 { font-size: 1.25em; }
.markdown h3 { font-size: 1.1em; }
.markdown blockquote { margin-left: 0; padding-left: 10px; border-left: 2px solid var(--line); color: var(--muted); }
.markdown a { color: var(--accent); }
.markdown :not(pre) > code { border-radius: 4px; padding: 1px 4px; background: var(--hover); }
.markdown :is(pre, th) { background: var(--sidebar); }
.markdown table { border-collapse: collapse; }
.markdown :is(th, td) { border: 1px solid var(--line); padding: 4px 8px; }
.turn-process { display: flex; align-items: center; min-width: 0; width: 100%; min-height: 33px; padding: 0 0 8px; border-bottom: 0.5px solid var(--line); text-align: left; white-space: pre; color: var(--process); font-size: 14px; }
.turn-process:hover:not(:disabled), .reasoning summary:hover { color: var(--muted); }
.turn-process svg { width: 14px; height: 14px; margin-left: 4px; transition: transform 100ms ease; }
.turn-process[aria-expanded="true"] svg { transform: rotate(180deg); }
.duration { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.reasoning { min-width: 0; color: var(--process); font-size: 13px; line-height: 20px; }
.reasoning summary { display: flex; align-items: center; min-width: 0; height: 24px; cursor: pointer; list-style: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning-leading { width: 16px; height: 16px; position: relative; display: grid; place-items: center; flex: none; margin-right: 6px; }
.reasoning-leading svg { width: 14px; height: 14px; stroke-width: 1; }
.reasoning-leading svg + svg { display: none; }
@media (hover: hover) {
  .reasoning summary:hover .reasoning-leading svg { display: none; }
  .reasoning summary:hover .reasoning-leading svg + svg { display: block; }
}
.reasoning[open] .reasoning-leading svg + svg { transform: rotate(180deg); }
.reasoning-dot { width: 2px; height: 2px; flex: none; border-radius: 50%; margin: 0 8px; background: currentColor; }
.reasoning-preview { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reasoning[data-streaming="true"] .reasoning-preview { mask-image: linear-gradient(to right, black calc(100% - 32px), transparent); }
.reasoning[open] :is(.reasoning-dot, .reasoning-preview), .reasoning-dot:has(+ .reasoning-preview:empty) { display: none; }
.reasoning-body { padding: 4px 0 4px 22px; }
.running-status { position: relative; color: var(--running); font-size: 12px; line-height: 22px; }
.running-status[data-has-output="true"]::before { content: ''; position: absolute; inset: -4px 0 auto; height: 0.5px; background: var(--line); }
.running-clock { display: inline-flex; height: 28px; margin-top: 4px; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.running-whale, .running-whale svg { width: 14px; height: 14px; }
.running-whale svg { stroke-width: 1; }
@supports (mask-image: url('')) {
  @media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
    .running-whale { background: currentColor; mask: url('/web/running-whale.png') center / contain no-repeat; }
    .running-whale svg { display: none; }
  }
}
@media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  .running-clock .shimmer, .reasoning[data-streaming="true"] .shimmer {
    background: linear-gradient(105deg, currentColor 40%, var(--shimmer-color) 50%, currentColor 60%) 100% / 250% 100%;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer-sweep 1.5s 0.3s steps(48, end) infinite;
  }
  .running-clock .shimmer { --shimmer-color: var(--running-shimmer); }
  .reasoning .shimmer { --shimmer-color: var(--process-shimmer); }
  @keyframes shimmer-sweep { 0% { background-position: 100%; } 66.6667%, 100% { background-position: 0%; } }
}
.response-state, .chat-status { margin: 0; color: var(--muted); font-size: 13px; }
.code-card { min-width: 0; border: 1px solid var(--line); background: var(--sidebar); border-radius: 12px; overflow: hidden; }
.code-heading { display: flex; justify-content: space-between; align-items: center; min-height: 38px; padding: 3px 9px 3px 13px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
pre { overflow: auto; margin: 0; max-height: 32rem; padding: 12px; tab-size: 2; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre code { font: inherit; }

.compose-area { align-self: center; width: 100%; min-width: 0; padding: 0 26px min(16vh, 135px); }
.has-thread .compose-area { padding: 8px 24px 16px; }
.hero { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 17px; }
.hero h1 { margin: 0; font-size: clamp(21px, 3vw, 26px); line-height: 1.25; font-weight: 500; }
.compose-wrap { width: min(100%, 790px); margin: 0 auto; }
.chat-status, #reload-models { margin-bottom: 7px; }
.composer { display: grid; gap: 8px; padding: 10px 11px 9px 13px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
#draft { display: block; width: 100%; min-height: 46px; max-height: min(30vh, 200px); field-sizing: content; resize: none; padding: 2px; outline: none; font-size: 16px; line-height: 24px; }
.has-thread #draft { min-height: 30px; }
#draft::placeholder, input::placeholder { color: var(--faint); }
.compose-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.attach-button { margin-inline-end: auto; }
.attachment-status { margin: 0; color: var(--muted); font-size: 12px; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.message.user:has(.chat-attachments) {
  display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding: 0; background: none;
}
.message.user .chat-attachments { justify-content: flex-end; }
.message-user-text { max-width: 100%; padding: 9px 15px; border-radius: 14px; background: var(--bubble); }
.attachment-tile {
  display: inline-flex; align-items: center; gap: 3px; max-width: 100%; min-width: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
}
.attachment-file {
  display: flex; align-items: center; gap: 7px; padding: 5px 7px;
  max-width: 220px; min-width: 0; color: var(--ink); text-decoration: none;
}
.attachment-file:hover { color: var(--accent); }
.attachment-file > svg { margin: 0 5px; color: var(--muted); flex: none; }
.attachment-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.attachment-remove { display: grid; place-items: center; flex: none; width: 26px; height: 32px; color: var(--muted); }
.attachment-remove:hover { color: var(--ink); }
.attachment-remove svg { width: 13px; height: 13px; }
.attachment-image { position: relative; border: 0; border-radius: 9px; background: transparent; }
.attachment-thumbnail { display: block; border-radius: inherit; overflow: hidden; cursor: zoom-in; }
.attachment-thumbnail img { display: block; width: 54px; height: 54px; object-fit: cover; }
.message .attachment-thumbnail img { width: 112px; height: 84px; }
.attachment-image .attachment-remove {
  position: absolute; inset: 2px 2px auto auto; width: 23px; height: 23px;
  border-radius: 50%; background: #151517b5; color: #fff;
}
.attachment-image .attachment-remove:hover { background: #151517; }
.image-preview {
  max-width: calc(100vw - 24px); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; background: transparent; overflow: visible;
}
.image-preview::backdrop { background: #101116d9; }
.image-preview > img {
  display: block; max-width: calc(100vw - 24px); max-height: calc(100dvh - 48px);
  width: auto; height: auto; object-fit: contain; border-radius: 8px;
}
.image-preview-close {
  position: fixed; inset: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) auto auto;
  border-radius: 50%; color: #fff;
}
.image-preview-close:is(:hover, :focus-visible) { background: #ffffff20; color: #fff; }
.send { display: grid; place-items: center; color: var(--paper); background: var(--ink); border-radius: 8px; width: 32px; height: 32px; flex: none; }
.send:disabled { color: var(--muted); background: var(--hover); }
.model-picker { position: relative; min-width: 0; }
.model-button { min-width: 0; max-width: 100%; height: 32px; display: flex; align-items: center; gap: 5px; padding: 0 6px 0 9px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.model-menu { position: absolute; z-index: 3; right: 0; bottom: calc(100% + 8px); width: min(300px, 75vw); border: 1px solid var(--line); box-shadow: 0 8px 24px #0002; background: var(--paper); border-radius: 12px; padding: 7px; }
.model-menu input { margin-bottom: 4px; padding: 6px 8px; }
.model-group { color: var(--muted); padding: 4px 7px; font-size: 13px; }
.model-options { max-height: min(40vh, 340px); overflow: auto; padding: 2px; }
.model-option { width: 100%; min-height: 34px; display: flex; align-items: center; gap: 6px; border-radius: 6px; padding: 6px; text-align: left; }
.model-option[aria-pressed="true"] { background: var(--sidebar); }
.model-option svg { margin-left: auto; color: var(--accent); }
.model-tag { font-size: 12px; flex: none; color: var(--muted); background: var(--hover); border-radius: 4px; padding: 1px 4px; }

.preview-splitter {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--sidebar);
  border-inline: 1px solid var(--line);
  cursor: col-resize;
  touch-action: none;
}
.preview-splitter::before { content: ''; width: 3px; height: 32px; border-radius: 3px; background: var(--faint); }
.preview-splitter:is(:hover, :focus-visible)::before, .app[data-resizing-preview] .preview-splitter::before { background: var(--accent); }
.app[data-resizing-preview] { cursor: col-resize; user-select: none; }
.app[data-resizing-preview] .preview-frame iframe { pointer-events: none; }
.preview { min-width: 0; min-height: 0; display: grid; grid-template-rows: 54px minmax(0, 1fr); background: var(--sidebar); }
.preview-header { display: flex; align-items: center; gap: 7px; padding: 8px 12px; }
.preview-header > svg { color: var(--muted); }
.preview-header strong { flex: 1; font-weight: 500; }
.preview-frame { margin: 0 9px 9px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 1050px) and (min-width: 761px) {
  .app { --history-width: 200px; }
  .app.with-preview { --history-width: 180px; }
  .with-preview .compose-area, .with-preview .thread { padding-inline: 12px; }
}
@media (max-width: 760px) {
  .app, .app.with-preview, .app.history-closed.with-preview { grid-template-columns: minmax(0, 1fr); }
  .app { position: relative; padding-top: env(safe-area-inset-top); }
  .sidebar { position: absolute; z-index: 7; inset: 0 auto 0 0; width: min(288px, 86vw); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .shade { position: absolute; z-index: 6; inset: 0; width: 100%; background: #15151742; }
  .app:not(.history-closed) #show-history { visibility: visible; width: 44px; margin-right: 0; }
  .preview { position: absolute; z-index: 5; inset: 0; border: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .preview-splitter { display: none; }
  .preview-frame { margin-inline: 6px; }
  .topbar { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .icon-button, .send { width: 44px; height: 44px; }
  .subtle, .model-button, .model-option, .history-item, .balance { min-height: 44px; }
  .model-menu { width: min(300px, calc(100vw - 88px)); }
  .model-options { max-height: max(44px, min(36dvh, calc(var(--app-height, 100dvh) - 158px), 328px)); }
  .compose-area, .has-thread .compose-area, .thread { padding-inline: 15px; }
  .has-thread .compose-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .compose-area { padding-bottom: min(10vh, 64px); }
  .sign-card { padding: 22px; }
  .model-menu input { font-size: 16px; }
}

/* Shared floating menus in the conversation sidebar. */
.client-menu {
  min-width: 136px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 8px 24px #11182724;
}
.client-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 6px;
  text-align: left;
  white-space: nowrap;
}
.client-menu button:hover, .client-menu button:focus-visible { background: var(--hover); }
.client-menu svg { width: 16px; height: 16px; }
.client-menu .destructive, #submit-history-action.danger { color: var(--error); }
#submit-history-action.danger { background: color-mix(in srgb, var(--error) 10%, var(--paper)); }
.history-actions { position: fixed; z-index: 12; }
.history-row { display: flex; align-items: center; min-width: 0; border-radius: 8px; }
.history-row:has([aria-current]), .history-row:hover { background: var(--hover); }
.history-row .history-item { flex: 1; min-width: 0; }
.history-spinner {
  width: 17px;
  height: 17px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
}
.history-row:not([data-generating]) .history-spinner, .history-row[data-generating] .history-item > svg { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .history-row[data-generating] .history-spinner { animation: history-spin .8s linear infinite; }
}
@keyframes history-spin { to { transform: rotate(360deg); } }
.history-more {
  display: grid;
  place-items: center;
  width: 30px;
  height: 32px;
  flex: none;
  margin-right: 3px;
  border-radius: 6px;
  color: var(--muted);
  opacity: 0;
}
.history-more:hover, .history-more[aria-expanded="true"] { background: var(--paper); }
.history-row:hover .history-more, .history-row:focus-within .history-more, .history-more[aria-expanded="true"] { opacity: 1; }
.account { position: relative; }
.account-launcher-menu { position: absolute; z-index: 4; inset: auto 0 calc(100% + 7px); }
.account-launcher-menu .account-logout { border-top: 1px solid var(--line); margin-top: 3px; border-top-left-radius: 0; border-top-right-radius: 0; }
.balance { -webkit-tap-highlight-color: transparent; }
.balance[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.balance-overview {
  position: absolute;
  z-index: 4;
  inset: auto auto calc(100% + 7px) 0;
  width: min(268px, calc(100vw - 24px));
  max-height: min(300px, calc(var(--app-height, 100dvh) - 76px));
  overflow: auto;
  padding: 14px 14px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  box-shadow: 0 8px 24px #11182724;
}
.balance-overview:focus { outline: none; }
.balance-overview h3 { margin: 0; font-size: 14px; font-weight: 600; }
.balance-overview p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.balance-overview-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 13px; }
.balance-overview-metrics div { min-width: 0; }
.balance-overview-metrics span { display: block; color: var(--muted); font-size: 12px; }
.balance-overview-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.balance-overview-body[aria-busy="true"] p { visibility: hidden; }
.balance-overview-body[aria-busy="true"] strong {
  width: min(72px, 100%);
  height: 17px;
  margin-block: 6px 4px;
  background: var(--hover);
  border-radius: 4px;
  color: transparent;
  animation: balance-pulse 1.1s ease-in-out infinite alternate;
}
@keyframes balance-pulse { from { opacity: .5; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .balance-overview-body[aria-busy="true"] strong { animation: none; }
}
.balance-overview-footer { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 5px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .balance-overview { width: min(268px, 100%); }
}
.desktop-auth-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.desktop-auth-actions > * { margin: 0; text-decoration: none; }
.history-name { width: 100%; min-height: 42px; border: 1px solid var(--line); padding: 6px 9px; border-radius: 8px; font-size: 16px; }

/* Keep the streaming rail steady when a narrow column truncates its text. */
.reasoning summary { display: flex; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.reasoning summary > :nth-child(2) { flex: none; }
.reasoning-preview { flex: 1 1 0; }
.running-clock { display: flex; max-width: 100%; white-space: nowrap; }
.running-whale { flex: none; }
.running-clock > .shimmer { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px), (hover: none) {
  .history-more { opacity: 1; height: 44px; width: 36px; }
  .client-menu button { min-height: 43px; }
}
.history-label { display: flex; justify-content: space-between; gap: 5px; }
#history-sync-status { font-size: 11px; color: var(--faint); white-space: nowrap; }
