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

.chat-page {
  height: 100vh;
  overflow: hidden;
  background: #f3f1eb;
}

.chat-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  min-width: 0;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #fbfaf7;
  flex-direction: column;
}

.chat-brand {
  margin-bottom: 20px;
}

.chat-brand div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.chat-brand strong {
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-brand span:not(.brand-mark) {
  color: var(--muted);
  font-size: 0.78rem;
}

.product-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.product-nav a {
  display: grid;
  min-height: 36px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.product-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(37, 34, 28, 0.1);
}

.new-session-button {
  display: flex;
  width: 100%;
  min-height: 42px;
  gap: 10px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
}

.new-session-button:hover {
  border-color: var(--accent);
}

.new-session-button svg,
.icon-button svg,
.send-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.session-summary {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.session-label,
.session-summary > span:last-child,
.chat-sidebar-footer span,
.chat-header p,
.draft-status,
.message-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.session-summary code {
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-sidebar-footer {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.chat-sidebar-footer div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-sidebar-footer strong,
.chat-sidebar-footer span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.chat-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.chat-header {
  display: flex;
  min-height: 72px;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.chat-header h1 {
  font-size: 1rem;
}

.chat-header p {
  margin-top: 4px;
}

.chat-header-actions,
.composer-tools,
.composer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-select-field {
  display: block;
  width: min(310px, 30vw);
  min-width: 190px;
}

.model-select-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 34px 0 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 750;
}

.fallback-toggle {
  display: flex;
  min-height: 40px;
  gap: 7px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 750;
}

.fallback-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.fallback-toggle:focus-within {
  outline: 3px solid rgba(23, 107, 101, 0.24);
  outline-offset: 2px;
}

.fallback-toggle:has(input:disabled) {
  opacity: 0.5;
}

.mobile-session-button {
  display: none;
}

.chat-elapsed {
  min-width: 62px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: right;
}

.icon-button,
.send-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
}

.icon-button[hidden],
.send-button[hidden] {
  display: none;
}

.icon-button {
  position: relative;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.send-button {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.send-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.send-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.stop-button {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--red);
}

.conversation {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px max(24px, calc((100% - 860px) / 2));
  scroll-behavior: smooth;
}

.chat-empty-state {
  display: grid;
  min-height: 100%;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 32px 0 80px;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid #b9d8d2;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #eef7f4;
}

.empty-mark svg {
  width: 23px;
  height: 23px;
}

.chat-empty-state h2 {
  font-size: 1.25rem;
}

.prompt-suggestions {
  display: flex;
  max-width: 720px;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.prompt-suggestions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 700;
}

.prompt-suggestions button:hover {
  border-color: var(--accent);
}

.message-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.message-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.message-user .message-avatar {
  color: var(--text);
  background: #e8e4da;
}

.message-column {
  min-width: 0;
}

.message-heading {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.message-heading strong {
  font-size: 0.88rem;
}

.message-content {
  max-width: 100%;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-content pre {
  max-height: none;
  margin: 12px 0;
  white-space: pre;
}

.message-content code:not(pre code) {
  border-radius: 4px;
  padding: 2px 5px;
  background: var(--surface-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
}

.message-status-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.message-status-line {
  display: flex;
  gap: 9px;
  align-items: center;
}

.status-pulse {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  animation: chat-pulse 1.3s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.message-attachments,
.message-images {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.message-attachment {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  width: min(260px, 100%);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.message-attachment-preview {
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 6px;
  background: #e8e4da;
}

.message-attachment-preview img,
.message-attachment-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-attachment-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #e4f1ee;
}

.message-attachment-icon svg {
  width: 17px;
  height: 17px;
}

.message-attachment-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.message-attachment-copy strong,
.message-attachment-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment-copy strong {
  font-size: 0.78rem;
}

.message-attachment-copy span {
  color: var(--muted);
  font-size: 0.7rem;
}

.message-images img {
  width: min(440px, 100%);
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1efe8;
}

.message-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.copy-message-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.copy-message-button:hover {
  color: var(--accent-strong);
  background: var(--surface-muted);
}

.copy-message-button svg {
  width: 16px;
  height: 16px;
}

.chat-error {
  margin: 0 auto 10px;
  width: min(860px, calc(100% - 48px));
  border: 1px solid rgba(180, 35, 24, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  color: #7a2018;
  background: #fff4f2;
  font-size: 0.84rem;
}

.chat-error[hidden] {
  display: none;
}

.message-column > .chat-error {
  width: 100%;
  margin: 8px 0 0;
}

.chat-composer.dragging {
  border-color: var(--accent);
  background: #eef7f4;
}

.chat-composer {
  width: min(900px, calc(100% - 48px));
  margin: 0 auto 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(37, 34, 28, 0.1);
}

.attachment-tray {
  display: flex;
  gap: 8px;
  padding: 10px 10px 0;
  overflow-x: auto;
}

.attachment-tray[hidden] {
  display: none;
}

.draft-attachment {
  position: relative;
  display: grid;
  grid-template-columns: 40px 130px;
  min-width: 190px;
  gap: 8px;
  align-items: center;
  padding: 6px 34px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.draft-attachment-preview {
  display: grid;
  width: 40px;
  height: 40px;
  overflow: hidden;
  place-items: center;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #e4f1ee;
}

.draft-attachment-preview img,
.draft-attachment-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.draft-attachment-preview svg {
  width: 18px;
  height: 18px;
}

.draft-attachment-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.draft-attachment-copy strong,
.draft-attachment-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-attachment-copy strong {
  font-size: 0.76rem;
}

.draft-attachment-copy span {
  color: var(--muted);
  font-size: 0.68rem;
}

.draft-remove {
  position: absolute;
  top: 7px;
  right: 6px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.draft-remove:hover {
  color: var(--red);
  background: #fff0ee;
}

.draft-remove svg {
  width: 15px;
  height: 15px;
}

.composer-input-wrap {
  display: block;
}

.chat-composer textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 220px;
  resize: none;
  border: 0;
  padding: 15px 16px 8px;
  background: transparent;
  line-height: 1.5;
}

.chat-composer textarea:focus {
  outline: 0;
}

.chat-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 101, 0.15), 0 10px 30px rgba(37, 34, 28, 0.1);
}

.composer-toolbar {
  display: flex;
  min-height: 52px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
}

@media (prefers-reduced-motion: reduce) {
  .conversation {
    scroll-behavior: auto;
  }

  .status-pulse {
    animation: none;
  }
}

@media (max-width: 1100px) and (min-width: 761px) {
  .model-select-field {
    width: 230px;
    min-width: 170px;
  }

  .fallback-toggle {
    grid-column: 1 / -1;
    min-height: 34px;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .chat-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .chat-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-brand {
    margin: 0;
  }

  .chat-brand .brand-mark {
    width: 36px;
    height: 36px;
  }

  .product-nav {
    width: 156px;
    margin: 0;
  }

  .new-session-button,
  .session-summary,
  .chat-sidebar-footer {
    display: none;
  }

  .chat-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 62px;
    padding: 10px 16px;
  }

  .chat-header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px 40px;
    grid-column: 1 / -1;
    width: 100%;
  }

  .model-select-field {
    width: 100%;
    min-width: 0;
  }

  .fallback-toggle {
    display: none;
  }

  .chat-elapsed {
    display: none;
  }

  .mobile-session-button {
    display: grid;
  }

  .chat-header p {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation {
    padding: 24px 16px;
  }

  .message-row {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 9px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.65rem;
  }

  .message-content {
    font-size: 0.92rem;
  }

  .chat-composer {
    width: calc(100% - 24px);
    margin-bottom: 12px;
  }

  .chat-error {
    width: calc(100% - 24px);
  }

  .draft-status {
    display: none;
  }
}
