:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --warm: #f0ebe2;
  --line: #e2e7ec;
  --line-strong: #ccd4dc;
  --text: #17202b;
  --muted: #697586;
  --muted-strong: #4b5768;
  --accent: #1769e0;
  --accent-strong: #0f52ba;
  --accent-soft: #eaf2ff;
  --violet: #6746df;
  --danger: #b42318;
  --danger-soft: #fbeae8;
  --shadow: 0 14px 38px rgba(16, 24, 40, 0.1);
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --visual-viewport-height: 100dvh;
  --visual-viewport-top: 0px;
  --keyboard-inset: 0px;
  --composer-height: 88px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  overflow: hidden;
  background: var(--bg);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

button,
[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.24);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* Hide controls injected by the known remove-web-limits-qixin browser script. */
remove-web-limits-qixin,
#rwl-qixin,
#rwl-setbtn,
qxinbutton,
lalala,
#rwl-qixin input[type="checkbox"],
body > input[type="checkbox"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.app-shell,
.login-view {
  position: fixed;
  top: var(--visual-viewport-top);
  right: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: var(--visual-viewport-height);
}

.app-shell {
  display: grid;
  overflow: hidden;
  grid-template-rows: calc(64px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  min-width: 0;
  background: var(--bg);
}

.login-view {
  z-index: 20;
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  -webkit-overflow-scrolling: touch;
}

.login-card {
  position: relative;
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: reveal 240ms ease both;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.login-mark {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.login-wordmark {
  display: block;
  width: 132px;
  height: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 680;
  line-height: 1.25;
}

.login-copy {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.login-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
}

.login-input-wrap {
  position: relative;
}

.login-input-wrap input {
  width: 100%;
  height: 50px;
  padding: 0 52px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: #ffffff;
  font-family: var(--mono);
  font-size: 16px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.login-input-wrap input:focus {
  border-color: rgba(23, 105, 224, 0.58);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.1);
}

.login-input-wrap button {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.login-input-wrap svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.login-button {
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  cursor: pointer;
  font-size: 15px;
  font-weight: 680;
}

.login-button:active {
  background: var(--accent-strong);
}

.login-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.login-error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.login-version {
  position: absolute;
  right: 13px;
  bottom: 10px;
  color: #98a2b3;
  font-family: var(--mono);
  font-size: 9px;
  user-select: none;
}

.topbar {
  z-index: 10;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) minmax(300px, 1fr);
  align-items: center;
  gap: 20px;
  padding:
    env(safe-area-inset-top)
    max(28px, env(safe-area-inset-right))
    0
    max(28px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand,
.header-actions,
.thread-title-wrap {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.brand-wordmark {
  display: block;
  width: 116px;
  height: 26px;
  object-fit: contain;
  object-position: left center;
}

.thread-title-wrap {
  overflow: hidden;
  text-align: center;
}

.thread-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
}

.thread-title-wrap h1 {
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: flex;
  height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  font-size: 12px;
  pointer-events: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d29b26;
}

.status-pill.online .status-dot {
  background: #15803d;
}

.status-pill.error .status-dot {
  background: var(--danger);
}

.icon-button,
.composer-button,
.send-button,
.copy-button,
.code-copy,
.artifact-download,
.attachment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:active,
.composer-button:active,
.send-button:active,
.copy-button:active,
.artifact-download:active {
  transform: scale(0.96);
}

.icon-button svg,
.composer-button svg,
.send-button svg,
.copy-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.new-thread,
.logout-button {
  min-width: 44px;
  height: 40px;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  font-size: 12px;
}

.logout-button {
  color: var(--muted-strong);
  border-color: var(--line);
  background: transparent;
}

.conversation {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding:
    22px
    max(20px, env(safe-area-inset-right), calc((100vw - 900px) / 2))
    34px
    max(20px, env(safe-area-inset-left), calc((100vw - 900px) / 2));
  scrollbar-color: #b4bec8 transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.welcome-panel {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 70px;
  text-align: center;
  animation: reveal 280ms ease both;
}

.welcome-panel.hidden {
  display: none;
}

.welcome-icon {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

.welcome-icon img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.welcome-panel h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 680;
  line-height: 1.25;
}

.message-list {
  width: 100%;
}

.message-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  animation: reveal 180ms ease both;
}

.message-row:last-child {
  border-bottom: 0;
}

.message-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  margin-top: 1px;
  overflow: hidden;
  color: #ffffff;
  border-radius: 8px;
  background: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 750;
}

.message-row.user .message-avatar {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: var(--warm);
}

.message-body,
.message-content {
  min-width: 0;
}

.message-heading {
  display: flex;
  min-height: 24px;
  align-items: baseline;
  gap: 10px;
}

.message-author {
  font-size: 13px;
  font-weight: 680;
}

.message-time {
  color: #8c98a8;
  font-family: var(--mono);
  font-size: 10px;
}

.message-content {
  overflow-wrap: anywhere;
  color: #344054;
  font-size: 14px;
  line-height: 1.75;
}

.message-content > :first-child {
  margin-top: 4px;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content p {
  margin: 10px 0;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 22px 0 8px;
  color: var(--text);
  line-height: 1.35;
}

.message-content h1 {
  font-size: 22px;
}

.message-content h2 {
  font-size: 18px;
}

.message-content h3 {
  font-size: 15px;
}

.message-content ul,
.message-content ol {
  padding-left: 22px;
}

.message-content li {
  margin: 5px 0;
}

.message-content strong {
  color: var(--text);
  font-weight: 680;
}

.message-content a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.message-content blockquote {
  margin: 12px 0;
  padding: 2px 0 2px 14px;
  color: var(--muted-strong);
  border-left: 3px solid rgba(23, 105, 224, 0.48);
}

.message-content code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef1f4;
  font-family: var(--mono);
  font-size: 0.9em;
}

.code-block {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  margin: 14px 0;
  border: 1px solid #27313b;
  border-radius: 8px;
  background: #0c1117;
}

.code-header {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 12px;
  color: #aab4c0;
  border-bottom: 1px solid #27313b;
  background: #151c24;
  font-family: var(--mono);
  font-size: 10px;
}

.code-copy {
  min-width: 56px;
  min-height: 44px;
  color: #c5ced8;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 11px;
}

.code-block pre {
  max-width: 100%;
  overflow-x: auto;
  margin: 0;
  padding: 15px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.code-block pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: #e6edf3;
  line-height: 1.7;
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.message-content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 13px;
}

.message-content th,
.message-content td {
  padding: 9px 11px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.message-content th {
  color: var(--text);
  background: var(--panel-soft);
  font-weight: 680;
}

.message-content tr:last-child td {
  border-bottom: 0;
}

.message-content th:last-child,
.message-content td:last-child {
  border-right: 0;
}

.typing-cursor::after {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--accent);
  content: "";
  animation: blink 900ms steps(1) infinite;
}

.message-actions {
  min-height: 44px;
  margin-top: 6px;
}

.message-status {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 5px 10px 5px 7px;
  color: #8a3a32;
  border: 1px solid #efc8c4;
  border-radius: 999px;
  background: var(--danger-soft);
  font-family: var(--mono);
  font-size: 10px;
}

.message-status[hidden] {
  display: none;
}

.message-status-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: #ffffff;
  border-radius: 50%;
  background: #a9443a;
  font-size: 13px;
}

.copy-button {
  min-width: 66px;
  min-height: 44px;
  visibility: hidden;
  gap: 6px;
  padding: 0 9px;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 11px;
}

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

.message-row:hover .copy-button,
.copy-button:focus-visible {
  visibility: visible;
}

.message-attachments:empty,
.activity-list:empty,
.artifact-list:empty {
  display: none;
}

.message-attachments {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 8px;
  margin: 7px 0 9px;
}

.attachment-card,
.attachment-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attachment-card {
  max-width: min(100%, 320px);
  min-height: 44px;
  padding: 7px 10px;
}

.attachment-card.downloadable {
  cursor: pointer;
}

.attachment-card.downloading {
  cursor: wait;
  opacity: 0.62;
}

.attachment-card-icon {
  flex: 0 0 auto;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.attachment-card-text {
  min-width: 0;
}

.attachment-card-name {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-card-size {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.activity-list {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-left: 3px solid rgba(23, 105, 224, 0.35);
  background: #f2f6fc;
}

.activity-item {
  display: grid;
  min-width: 0;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted-strong);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.activity-item + .activity-item {
  margin-top: 5px;
}

.activity-symbol {
  color: var(--accent);
}

.activity-detail {
  color: var(--muted);
}

.artifact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  align-items: start;
  gap: 10px;
  margin-top: 16px;
}

.artifact-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.artifact-preview {
  display: block;
  width: 100%;
  max-height: min(40dvh, 360px);
  object-fit: contain;
  border-bottom: 1px solid var(--line);
  background: #edf1f5;
}

.artifact-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 9px;
}

.artifact-type {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--violet);
  border: 1px solid #ddd5ff;
  border-radius: 7px;
  background: #f3f0ff;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 750;
}

.artifact-info {
  min-width: 0;
  flex: 1;
}

.artifact-name {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-size {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.artifact-download {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.artifact-download:disabled,
.artifact-download.downloading {
  cursor: wait;
  opacity: 0.5;
}

.artifact-download.ready-to-share,
.attachment-card.ready-to-share {
  color: var(--accent);
  border-color: #9fc1f2;
  background: var(--accent-soft);
}

.artifact-download svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.artifact-download-label {
  display: none;
}

.artifact-card.downloadable {
  cursor: pointer;
}

.composer-dock {
  z-index: 8;
  width: min(932px, 100%);
  margin: 0 auto;
  padding:
    0
    max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.attachment-tray {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  gap: 8px;
  padding: 0 2px 8px;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.attachment-chip {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 0 0 11px;
  font-size: 10px;
}

.attachment-chip-name {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.composer {
  display: grid;
  grid-template-areas: "attach prompt model send";
  grid-template-columns: 44px minmax(0, 1fr) minmax(120px, auto) 44px;
  align-items: end;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.1);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer:focus-within {
  border-color: rgba(23, 105, 224, 0.5);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.1), 0 0 0 3px rgba(23, 105, 224, 0.08);
}

.composer-button,
.send-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
}

.composer-button {
  grid-area: attach;
  color: var(--muted-strong);
  background: var(--panel-soft);
}

.composer-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

#prompt-input {
  grid-area: prompt;
  overflow-y: auto;
  width: 100%;
  min-height: 44px;
  max-height: min(180px, 35dvh);
  padding: 10px 6px 8px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

#prompt-input::placeholder {
  color: #98a2b3;
}

.model-readout {
  display: flex;
  max-width: 190px;
  height: 32px;
  grid-area: model;
  align-self: center;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  overflow: hidden;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.model-spark {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--violet);
}

#model-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-button {
  grid-area: send;
  color: #ffffff;
  background: var(--accent);
}

.send-button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
  background: #e4e9ee;
}

.stop-icon,
.stop-label {
  display: none;
}

.composer.running .send-icon {
  display: none;
}

.composer.running .stop-icon {
  display: block;
  width: 16px;
  height: 16px;
}

.composer.running .stop-label {
  display: inline;
}

.composer.running { grid-template-columns: 44px minmax(0, 1fr) minmax(120px, auto) 68px; }

.composer.running .send-button {
  width: 68px;
  gap: 5px;
  color: #704b47;
  border: 1px solid rgba(151, 94, 87, 0.16);
  background: #ead1cd;
  font-size: 11px;
  font-weight: 680;
}

.composer.running.stopping .send-button {
  opacity: 0.72;
}

.composer-meta {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 20px;
  padding: 7px 5px 0;
  color: #7c8796;
  font-family: var(--mono);
  font-size: 9px;
}

.composer-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

kbd {
  font-family: inherit;
}

.toast-region {
  position: fixed;
  z-index: 50;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom) + var(--keyboard-inset));
  display: grid;
  width: min(360px, calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 11px 13px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  animation: reveal 160ms ease both;
}

.toast.error {
  border-color: #e9a7a0;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (hover: hover) and (pointer: fine) {
  .login-input-wrap button:hover,
  .composer-button:hover,
  .copy-button:hover,
  .code-copy:hover {
    color: var(--text);
    background: #eef2f6;
  }

  .login-button:hover,
  .send-button:hover {
    background: var(--accent-strong);
  }

  .new-thread:hover {
    border-color: #aeb8c3;
    background: var(--panel-soft);
  }

  .logout-button:hover {
    color: var(--danger);
    border-color: #e7aaa4;
    background: var(--danger-soft);
  }

  .artifact-download:hover,
  .attachment-card.downloadable:hover {
    color: var(--accent);
    border-color: #a9c8f6;
    background: var(--accent-soft);
  }

  .attachment-remove:hover {
    color: var(--danger);
    background: var(--danger-soft);
  }

  .composer.running .send-button:hover {
    color: #65413d;
    background: #e2c2bd;
  }
}

@media (hover: none), (pointer: coarse) {
  .new-thread,
  .logout-button {
    height: 44px;
  }

  .copy-button {
    visibility: visible;
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-rows: calc(62px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  .topbar {
    grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1.2fr) minmax(280px, 1fr);
    gap: 14px;
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .conversation {
    padding-right: max(22px, env(safe-area-inset-right));
    padding-left: max(22px, env(safe-area-inset-left));
  }

  .brand-wordmark {
    width: 104px;
  }

  .status-pill {
    padding: 0 10px;
  }

  .new-thread,
  .logout-button {
    height: 44px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    grid-template-rows: calc(58px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 9px;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .brand {
    gap: 0;
  }

  .brand-wordmark,
  .thread-kicker,
  .header-actions .icon-button span,
  #status-label {
    display: none;
  }

  .thread-title-wrap {
    text-align: left;
  }

  .thread-title-wrap h1 {
    font-size: 13px;
  }

  .header-actions {
    gap: 2px;
  }

  .status-pill {
    width: 18px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .new-thread,
  .logout-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border-color: transparent;
    background: transparent;
  }

  .conversation {
    padding:
      10px
      max(14px, env(safe-area-inset-right))
      22px
      max(14px, env(safe-area-inset-left));
  }

  .welcome-panel {
    justify-content: flex-start;
    padding: min(13vh, 76px) 10px 48px;
  }

  .welcome-icon {
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
  }

  .welcome-panel h2 {
    font-size: 26px;
  }

  .message-row {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    padding: 17px 0;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    font-size: 9px;
  }

  .message-content {
    font-size: 14px;
    line-height: 1.7;
  }

  .message-content h1 {
    font-size: 20px;
  }

  .message-content h2 {
    font-size: 17px;
  }

  .message-content ul,
  .message-content ol {
    padding-left: 19px;
  }

  .message-actions {
    margin-top: 2px;
  }

  .message-attachments {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    -webkit-overflow-scrolling: touch;
  }

  .attachment-card {
    max-width: 82vw;
    flex: 0 0 auto;
  }

  .artifact-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .artifact-preview {
    max-height: min(34dvh, 280px);
  }

  .artifact-download {
    width: 72px;
    gap: 6px;
    font-size: 12px;
    font-weight: 650;
  }

  .artifact-download-label {
    display: inline;
  }

  .composer-dock {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .composer {
    grid-template-areas:
      "prompt prompt prompt"
      "attach model send";
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 5px 7px;
    padding: 7px;
  }

  .composer.running {
    grid-template-columns: 44px minmax(0, 1fr) 68px;
  }

  #prompt-input {
    min-height: 42px;
    max-height: min(150px, 30dvh);
    padding: 7px 5px 5px;
  }

  .model-readout {
    width: 100%;
    max-width: none;
  }

  .composer-meta {
    justify-content: flex-end;
    padding-top: 5px;
  }

  .composer-meta span:first-child {
    display: none;
  }

  .attachment-chip-name {
    max-width: 150px;
  }

  .toast-region {
    right: max(10px, env(safe-area-inset-right));
    width: calc(100vw - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right)));
  }
}

@media (max-width: 390px) {
  .login-view {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .login-card {
    padding: 26px 20px;
  }

  .login-brand {
    margin-bottom: 24px;
  }

  .login-wordmark {
    width: 118px;
  }

  .login-card h1 {
    font-size: 25px;
  }

  .status-pill {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 7px);
    left: calc(max(10px, env(safe-area-inset-left)) + 29px);
    display: flex;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #ffffff;
  }

  .status-pill .status-dot {
    width: 8px;
    height: 8px;
  }

  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) 88px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .app-shell {
    grid-template-rows: calc(52px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  .login-view {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .login-card {
    max-width: 560px;
    padding: 20px 24px;
  }

  .login-brand {
    margin-bottom: 12px;
  }

  .login-mark {
    width: 40px;
    height: 40px;
  }

  .login-wordmark {
    width: 110px;
  }

  .login-card h1 {
    font-size: 22px;
  }

  .login-copy {
    margin: 5px 0 12px;
  }

  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .brand-wordmark,
  .thread-kicker,
  .header-actions .icon-button span,
  #status-label {
    display: none;
  }

  .thread-title-wrap {
    text-align: left;
  }

  .status-pill {
    width: 18px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .new-thread,
  .logout-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border-color: transparent;
    background: transparent;
  }

  .conversation {
    padding-top: 8px;
    padding-bottom: 14px;
  }

  .welcome-panel {
    justify-content: flex-start;
    padding-top: 18px;
    padding-bottom: 24px;
  }

  .welcome-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
  }

  .welcome-panel .eyebrow {
    display: none;
  }

  .welcome-panel h2 {
    font-size: 22px;
  }

  .composer-dock {
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .composer-meta {
    display: none;
  }
}

.mobile-download-document {
  min-height: 100%;
  height: auto;
  overflow: auto;
}

body.mobile-download-page {
  display: grid;
  min-height: 100dvh;
  height: auto;
  overflow: auto;
  place-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: #f4f7fb;
}

.mobile-download-card {
  width: min(88vw, 440px);
  padding: 28px;
  text-align: center;
  border: 1px solid #dfe6ef;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(30, 50, 80, 0.12);
}

.mobile-download-card h1 {
  margin: 0;
  font-size: 21px;
}

.mobile-download-detail {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
  color: #617087;
  font-size: 14px;
  line-height: 1.65;
}

.mobile-download-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 18px;
  border: 3px solid #d8e5f7;
  border-top-color: #216fd1;
  border-radius: 50%;
  animation: mobile-download-spin 0.8s linear infinite;
}

.mobile-download-error {
  color: var(--danger);
}

.mobile-download-link {
  display: flex;
  min-height: 48px;
  margin-top: 22px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border-radius: 10px;
  background: var(--accent);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@keyframes mobile-download-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
