:root {
  color-scheme: light;
  --composer-height: 72px;
  --bg: #ffffff;
  --surface: #f7f7f5;
  --surface-2: #f1f1ef;
  --line: #e3e3df;
  --line-strong: #d8d8d2;
  --text: #0d0d0d;
  --muted: #6f6f6f;
  --soft: #8a8a8a;
  --hover: #ececea;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.pwa-gate[aria-hidden="true"],
.auth-screen[aria-hidden="true"],
.app-shell[aria-hidden="true"],
.console-page[aria-hidden="true"] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}

body.artifact-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled {
  cursor: default;
  opacity: 0.55;
}

.booting {
  visibility: hidden;
}

.pwa-gated {
  overflow: hidden;
}

.pwa-gate {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  background: #fff;
}

.pwa-gate-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  align-content: start;
}

.pwa-gate-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  background: #111;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.pwa-gate-card h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: 0;
}

.pwa-gate-copy,
.pwa-gate-hint,
.pwa-ios-guide {
  margin: 0;
  color: #686864;
  font-size: 14px;
  line-height: 1.62;
}

.pwa-ios-guide {
  border: 1px solid #ecece8;
  border-radius: 14px;
  padding: 13px 14px;
  background: #fbfbfa;
}

.pwa-ios-guide p {
  margin: 0 0 8px;
  color: #111;
  font-weight: 650;
}

.pwa-ios-guide ol {
  margin: 0;
  padding-left: 20px;
}

.pwa-ios-guide li {
  margin: 5px 0;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: #fff;
}

.auth-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 22px;
}

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

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-weight: 700;
}

.brand-mark {
  width: 42px;
  height: 42px;
  font-size: 13px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
}

.auth-brand p,
.console-header p,
.console-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-tabs {
  display: inline-flex;
  width: max-content;
  border-radius: 999px;
  padding: 3px;
  background: var(--surface-2);
}

.auth-tabs button {
  height: 34px;
  border-radius: 999px;
  padding: 0 16px;
  background: transparent;
  color: #555;
}

.auth-tabs button.active {
  background: #fff;
  color: #111;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
.metric-card span,
.usage-grid span {
  color: #333;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #111;
  outline: 0;
}

input:focus,
textarea:focus {
  border-color: #111;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid #ececec;
  background: #fff;
  overflow: hidden;
  color: #0d0d0d;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 8px 10px 6px 12px;
}

.brand-button {
  display: inline-flex;
  min-width: 0;
  height: 36px;
  align-items: center;
  gap: 5px;
  border-radius: 10px;
  padding: 0 9px;
  background: transparent;
  color: #171717;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand-button:hover {
  background: #efefed;
}

.brand-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  color: #111;
}

.icon-button svg,
.nav-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.icon-button:hover,
.nav-item:hover {
  background: #efefed;
}

.nav-list {
  display: grid;
  gap: 1px;
  padding: 2px 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  border-radius: 10px;
  padding: 0 10px;
  background: transparent;
  color: #171717;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item svg {
  flex: 0 0 auto;
}

.nav-item.active {
  background: #eeeeeb;
}

.story-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(980px, calc(100% - 48px));
  min-height: 100vh;
  gap: 16px;
  align-content: start;
  margin: 0 auto;
  padding: 64px 24px 220px;
  background: #fff;
}

.story-panel[hidden] {
  display: none !important;
}

.story-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #ecece8;
  padding-bottom: 16px;
}

.story-panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.story-template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.story-template-grid button {
  display: grid;
  gap: 5px;
  min-height: 118px;
  border: 1px solid #ecece8;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  color: #111;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, translate 0.16s ease;
}

.story-template-grid button:hover {
  border-color: #deded9;
  background: #fbfbfa;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  translate: 0 -1px;
}

.story-template-grid strong {
  font-size: 14px;
  font-weight: 600;
}

.story-template-grid span {
  color: #666;
  font-size: 12px;
  line-height: 1.45;
}

.recent-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0 8px 8px;
}

.recent-title {
  padding: 11px 9px 6px;
  color: #5f5f5b;
  font-size: 13px;
  font-weight: 600;
}

.history-list {
  display: grid;
  gap: 0;
  max-height: none;
  overflow: auto;
  padding-right: 0;
  scrollbar-width: none;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px 24px;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  width: 100%;
  min-height: 34px;
  border-radius: 10px;
  padding: 0 4px 0 9px;
  background: transparent;
  color: #171717;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  transition: background-color 0.12s ease;
}

.history-image-status {
  display: block;
  justify-self: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
}

.history-image-status.generating {
  border: 2px solid #d9ecff;
  border-top-color: #2f9bff;
  border-right-color: #2f9bff;
  animation: spin 820ms linear infinite;
}

.history-image-status.done {
  width: 7px;
  height: 7px;
  background: #2f9bff;
  box-shadow: 0 0 0 3px #e8f3ff;
}

.history-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item:hover,
.history-item.active {
  background: #efefed;
}

.history-delete {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  color: #686864;
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.history-item:hover .history-delete,
.history-delete:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.history-item:hover .history-image-status {
  opacity: 0;
}

.history-delete:hover {
  background: #e3e3df;
  color: #111;
}

.empty-history {
  padding: 9px;
  color: #8a8a84;
  font-size: 13px;
}

.profile-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px;
  border-radius: 12px;
  padding: 8px;
  text-align: left;
  user-select: none;
  transition: background-color 0.12s ease;
}

.profile-card:hover {
  background: #efefed;
}

.avatar {
  width: 30px;
  height: 30px;
  border: 1px solid #d8d8d4;
  background: #111;
  font-size: 12px;
}

.avatar.large {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.profile-meta {
  min-width: 0;
}

.profile-name {
  overflow: hidden;
  line-height: 1.2;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-plan {
  margin-top: 1px;
  line-height: 1.2;
  color: #777771;
  font-size: 12px;
}

.profile-more {
  width: 32px;
  height: 32px;
  color: #5f5f5b;
}

.chat-area {
  position: relative;
  display: grid;
  min-height: 100vh;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  background: #fff;
}

.floating-sidebar {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 22;
  background: #f5f5f5;
}

.welcome {
  position: absolute;
  top: 31.5%;
  left: 50%;
  translate: -50% 0;
  width: min(92vw, 780px);
  text-align: center;
  pointer-events: none;
}

.welcome h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0;
}

.welcome.hidden {
  display: none;
}

.story-open .conversation,
.story-open .welcome {
  display: none;
}

.story-open .composer-wrap {
  top: auto;
  bottom: 24px;
}

.story-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.story-background-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 15, 15, 0.22);
  backdrop-filter: blur(3px);
}

.story-background-modal[hidden] {
  display: none;
}

.story-background-card {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.22);
}

.story-background-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.story-background-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0;
}

.story-background-subtitle {
  max-width: 520px;
  margin: 8px 0 0;
  color: #6f6f69;
  font-size: 13px;
  line-height: 1.6;
}

.story-background-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.story-background-grid > label:first-child,
.story-background-grid > label:last-child {
  grid-column: 1 / -1;
}

.story-background-grid label {
  gap: 8px;
}

.story-select-stack {
  display: grid;
  min-height: 100%;
  align-content: center;
  gap: 14px;
}

.story-select-stack label {
  gap: 8px;
}

.story-background-grid label span {
  color: #252522;
  font-size: 12px;
  font-weight: 700;
}

.story-background-grid textarea,
.story-background-grid select {
  width: 100%;
  border: 1px solid #dfdfda;
  border-radius: 12px;
  background: #fbfbfa;
  color: #151512;
  font: inherit;
  outline: 0;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.story-background-grid textarea {
  min-height: 92px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.55;
}

.story-background-grid select {
  height: 44px;
  padding: 0 12px;
}

.story-background-grid textarea::placeholder {
  color: #999993;
}

.story-background-grid textarea:focus,
.story-background-grid select:focus {
  border-color: #111;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06);
}

.story-background-grid p {
  margin: 0;
  color: #6b6b66;
  font-size: 14px;
  line-height: 1.6;
}

.story-background-card .settings-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #eeeeeb;
}

.conversation {
  min-height: 100vh;
  width: min(900px, calc(100vw - 320px));
  margin: 0 auto;
  padding: 76px 24px 210px;
  overscroll-behavior: contain;
}

.console-page::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.artifact-body::-webkit-scrollbar,
.markdown-body .table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.console-page::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.artifact-body::-webkit-scrollbar-thumb,
.markdown-body .table-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.console-page::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.artifact-body::-webkit-scrollbar-track,
.markdown-body .table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 16px 0;
}

.message.user {
  align-items: flex-end;
}

.bubble {
  width: fit-content;
  min-width: 0;
  max-width: min(780px, 100%);
  border-radius: 22px;
  padding: 12px 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

.message.user .bubble {
  min-width: 36px;
  background: #f4f4f4;
}

.message.assistant .bubble {
  padding-left: 0;
  background: transparent;
  max-width: 100%;
}

.message.assistant {
  width: 100%;
}

.message.assistant .markdown-body {
  width: min(780px, 100%);
}

.message.error .bubble {
  border: 1px solid #ffd0d0;
  background: #fff5f5;
  color: var(--danger);
}

.bubble.thinking {
  color: #777;
}

.thinking-line {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 6px;
  margin: 0 0 4px;
  padding: 0;
  background: transparent;
  color: #8a8178;
  font-size: 14px;
}

.thinking-line:hover {
  color: #5f574f;
}

.thinking-line .thinking-time {
  color: inherit;
}

.thinking-line .chevron {
  font-size: 18px;
  line-height: 1;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-right: 2px;
}

.thinking-dots i {
  width: 3.5px;
  height: 3.5px;
  border-radius: 999px;
  background: currentColor;
  animation: thinkingPulse 1.2s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 0.14s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes thinkingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.markdown-body {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.markdown-body p {
  margin: 0 0 12px;
}

.markdown-body p:last-child,
.markdown-body ul:last-child,
.markdown-body ol:last-child,
.markdown-body blockquote:last-child,
.markdown-body .table-wrap:last-child,
.markdown-body pre:last-child {
  margin-bottom: 0;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 18px 0 8px;
  color: #111;
  font-weight: 650;
  line-height: 1.35;
}

.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child {
  margin-top: 0;
}

.markdown-body h2 {
  font-size: 20px;
}

.markdown-body h3 {
  font-size: 18px;
}

.markdown-body h4 {
  font-size: 16px;
}

.markdown-body strong {
  font-weight: 700;
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  color: #6f6f6a;
  text-decoration-color: #a9a9a4;
}

.markdown-body hr {
  height: 1px;
  border: 0;
  margin: 18px 0;
  background: #e7e7e3;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.markdown-body li {
  margin: 4px 0;
}

.markdown-body .task-item {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
}

.markdown-body .task-item input {
  width: 15px;
  height: 15px;
  margin-top: 6px;
  accent-color: #111;
}

.markdown-body blockquote {
  border-left: 3px solid #d7d7d2;
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  color: #565656;
}

.markdown-body a {
  color: #0b57d0;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body .markdown-link.compact {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border-radius: 999px;
  padding: 1px 7px;
  background: #f2f2f0;
  color: #4f4f4b;
  font-size: 0.9em;
  vertical-align: baseline;
}

.markdown-body .markdown-link.compact:hover {
  background: #e8e8e5;
  color: #111;
  text-decoration: none;
}

.markdown-body .citation-ref {
  display: inline-flex;
  min-width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  margin: 0 1px;
  padding: 0 4px;
  background: #f1f1ef;
  color: #5f5f59;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  vertical-align: super;
}

.markdown-body .markdown-image {
  display: block;
  max-width: min(520px, 100%);
  margin: 8px 0 12px;
}

.markdown-body .markdown-image a {
  display: block;
  overflow: hidden;
  border: 1px solid #ecece8;
  border-radius: 8px;
  background: #f7f7f5;
}

.markdown-body .markdown-image img {
  display: block;
  width: 100%;
  height: auto;
}

.markdown-body .markdown-image-caption {
  display: block;
  margin-top: 6px;
  color: #777;
  font-size: 12px;
}

.markdown-body code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #f1f1ef;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 0.92em;
}

.markdown-body .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 12px 0;
  padding: 2px 0 4px;
}

.markdown-body .katex {
  font-size: 1.04em;
}

.markdown-body .math-fallback {
  border-radius: 5px;
  padding: 1px 5px;
  background: #f7f7f5;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
}

.markdown-body .math-fallback.display {
  display: block;
  overflow-x: auto;
  margin: 12px 0;
  padding: 10px 12px;
  white-space: pre;
}

.markdown-body .code-block {
  position: relative;
  overflow: auto;
  border-radius: 8px;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid #ecece8;
  background: #fff;
}

.markdown-body .code-block.streaming {
  outline: 1px solid #e8e8e4;
}

.markdown-body .code-block.text-block {
  border: 0;
  border-radius: 6px;
  background: #f7f7f5;
}

.markdown-body .code-block code {
  display: block;
  padding: 14px;
  background: transparent;
  white-space: pre;
}

.markdown-body .code-block.text-block code {
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  white-space: pre-wrap;
}

.code-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e7e7e3;
  padding: 0 12px;
  background: #fff;
  color: #555;
  font-size: 12px;
}

.code-toolbar button {
  border-radius: 6px;
  padding: 5px 8px;
  background: transparent;
  color: #444;
  font-size: 12px;
}

.code-toolbar button:hover {
  background: #f1f1ef;
}

.code-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.markdown-body .table-wrap {
  max-width: 100%;
  overflow: auto;
  margin: 0 0 12px;
}

.markdown-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border-bottom: 1px solid #e6e6e3;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: #f7f7f5;
  font-weight: 650;
}

.source-tray {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 6px;
}

.source-chip,
.inline-source-chip {
  display: inline-flex;
  max-width: 220px;
  height: 24px;
  align-items: center;
  overflow: hidden;
  border-radius: 999px;
  padding: 0 9px;
  background: #f2f2f0;
  color: #4f4f4b;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-chip:hover,
.inline-source-chip:hover {
  background: #e7e7e4;
  color: #111;
  text-decoration: none;
}

.inline-source-tray {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 12px;
}

.artifact-tray {
  display: grid;
  width: min(620px, calc(100% - 6px));
  gap: 8px;
  margin: 8px 0 6px;
}

.artifact-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  border: 1px solid #e5e5e2;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: #111;
  text-align: left;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.artifact-card:hover {
  border-color: #d7d7d2;
  background: #fbfbfa;
}

.artifact-card-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: #f2fbff;
  color: #0b84d8;
  font-size: 18px;
  font-weight: 700;
}

.artifact-card-meta {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.artifact-card-meta strong,
.artifact-card-meta em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-card-meta strong {
  font-size: 14px;
  font-weight: 600;
}

.artifact-card-meta em {
  color: #777;
  font-size: 13px;
  font-style: normal;
}

.artifact-card-open {
  border-radius: 999px;
  padding: 6px 12px;
  background: #f7f7f5;
  color: #111;
  font-size: 13px;
}

.generated-image-grid {
  display: grid;
  width: min(480px, 100%);
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin: 10px 0;
}

.generated-image-card {
  overflow: hidden;
  border: 0;
  border-radius: 34px;
  margin: 0;
  background: #f5f5f5;
  max-width: 480px;
}

.generated-image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f4f4f2;
  cursor: zoom-in;
}

.generated-image-card.placeholder {
  pointer-events: none;
  user-select: none;
}

.image-generation-status {
  display: grid;
  gap: 8px;
  color: #6e7480;
  font-size: 16px;
  line-height: 1.35;
}

.image-placeholder {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center start;
  overflow: hidden;
  border-radius: inherit;
  background: #f4f4f4;
}

.image-placeholder::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 48%, rgba(255,255,255,0.55) 70%, rgba(255,255,255,0.85) 100%);
  pointer-events: none;
}

.image-placeholder-dots {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: clamp(8px, 2.15vw, 14px);
  width: min(74%, 350px);
  margin-left: clamp(24px, 6vw, 50px);
}

.image-placeholder-dots i {
  display: block;
  width: clamp(2px, 0.62vw, 5px);
  height: clamp(2px, 0.62vw, 5px);
  border-radius: 999px;
  background: #7f858b;
  opacity: var(--dot-alpha, 0.2);
  transform: scale(var(--dot-scale, 1));
  animation: dotPulse 1800ms ease-in-out infinite;
  animation-delay: var(--dot-delay, 0ms);
}

@keyframes dotPulse {
  0%, 100% {
    opacity: calc(var(--dot-alpha, 0.2) * 0.55);
  }

  50% {
    opacity: var(--dot-alpha, 0.2);
  }
}

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

.generated-image-card figcaption {
  display: none;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #ecece8;
  padding: 8px;
  color: #777;
  font-size: 13px;
}

.generated-image-card.placeholder figcaption {
  justify-content: center;
  color: #8a8a84;
}

.generated-image-card a {
  border-radius: 999px;
  padding: 6px 10px;
  background: #f7f7f5;
  color: #111;
  font-size: 13px;
  text-decoration: none;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding: 52px 170px 120px 80px;
  background: rgba(255, 255, 255, 0.46);
  backdrop-filter: blur(18px) saturate(1.08);
}

.image-preview-modal[hidden] {
  display: none !important;
}

.image-preview-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: min(68vw, 800px);
  height: min(58vh, 520px);
  transform: translateY(-18px);
}

.image-preview-shell img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 24px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.18);
  object-fit: contain;
}

.image-preview-actions {
  position: absolute;
  top: -18px;
  right: -168px;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
}

.image-preview-download,
.image-preview-close {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #111;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(14px);
}

.image-preview-download {
  padding: 8px 14px;
  font-size: 14px;
  text-decoration: none;
}

.image-preview-close {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.image-preview-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

@media (max-width: 1180px) {
  .image-preview-modal {
    padding: 50px 120px 110px 38px;
  }

  .image-preview-shell {
    width: min(68vw, 760px);
    height: min(56vh, 500px);
    transform: translateY(-16px);
  }

  .image-preview-actions {
    top: -18px;
    right: -126px;
  }
}

.user-edit-form {
  display: grid;
  gap: 8px;
  width: min(640px, 70vw);
}

.user-edit-form textarea {
  min-height: 74px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  line-height: 1.55;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mini {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.message-actions {
  display: flex;
  gap: 2px;
  min-height: 32px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.message.assistant:hover .message-actions,
.message.user:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}

.user-actions {
  margin-right: 4px;
}

.message-action {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  color: #6f6f6f;
}

.message-action:hover {
  background: var(--hover);
  color: #111;
}

.message-action:disabled {
  pointer-events: none;
  opacity: 0.35;
}

.message-action.selected {
  background: var(--hover);
  color: #111;
}

.message-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.message-action.copy[data-done="true"]::after {
  content: "✓";
  font-size: 15px;
}

.message-action.copy[data-done="true"] svg {
  display: none;
}

.composer-wrap {
  position: fixed;
  top: calc(31.5% + 76px);
  right: 0;
  left: 260px;
  display: grid;
  justify-items: center;
  padding: 0 22px;
  pointer-events: none;
}

.has-messages .composer-wrap {
  top: auto;
  bottom: 24px;
}

.composer {
  position: relative;
  display: grid;
  width: min(768px, 100%);
  min-height: 58px;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  border: 1px solid #d9d9d6;
  border-radius: 29px;
  padding: 14px 10px 10px 22px;
  background: #fff;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.composer.has-attachments {
  border-radius: 30px;
  padding-top: 10px;
}

.composer-wrap.dragging .composer {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08), var(--shadow);
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 8px 2px 0;
}

.attachment-pill,
.attachment-chip {
  display: inline-flex;
  max-width: 260px;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid #e5e5e2;
  border-radius: 14px;
  padding: 6px 8px;
  background: #f4f4f2;
  color: #333;
  font-size: 12px;
  text-align: left;
}

.attachment-pill {
  cursor: default;
}

.attachment-pill {
  height: 64px;
  background: #fff;
}

.attachment-pill.image-pill {
  width: calc(68px * var(--thumb-ratio, 1) + 132px);
  min-width: 170px;
}

.attachment-preview,
.attachment-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 5px;
  background: #111;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

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

.attachment-pill.image-pill .attachment-preview {
  width: calc(48px * var(--thumb-ratio, 1));
  overflow: hidden;
  background: #eee;
}

.attachment-info {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.attachment-pill strong,
.attachment-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-pill em {
  color: #777;
  font-style: normal;
  white-space: nowrap;
}

.attachment-remove {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: #ececea;
  color: #555;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.attachment-pill:hover .attachment-remove,
.attachment-remove:hover {
  background: #111;
  color: #fff;
}

.attachment-tray {
  display: flex;
  max-width: min(620px, 78%);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.attachment-chip.image-chip {
  max-width: 320px;
}

.attachment-chip.image-chip img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 9px;
}

.composer textarea {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-height: 240px;
  min-height: 24px;
  resize: none;
  border: 0;
  outline: 0;
  color: #111;
  background: transparent;
  line-height: 24px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.composer textarea::placeholder {
  color: var(--soft);
}

.composer-footer {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 36px 38px;
  align-items: center;
  gap: 10px;
}

@media (max-width: 620px) {
  .composer-footer {
    grid-template-columns: 34px minmax(0, 1fr) auto 36px 38px;
    gap: 7px;
  }

  .model-pill {
    padding: 0 10px;
    font-size: 13px;
  }

  .voice-button,
  .send-button {
    flex: 0 0 auto;
  }
}

.composer-spacer {
  display: none;
}

.composer-tool {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  color: #111;
}

.composer-tool:hover {
  background: #f2f2f0;
}

.composer-tool svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.model-pill {
  display: inline-flex;
  height: 36px;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 0 13px;
  background: #f4f4f4;
  color: #555;
  font-size: 14px;
  white-space: nowrap;
}

.model-pill:hover,
.model-pill[aria-expanded="true"] {
  background: #ededeb;
  color: #111;
}

.model-pill svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.model-menu {
  position: absolute;
  right: 58px;
  bottom: 52px;
  z-index: 28;
  display: grid;
  width: 232px;
  gap: 4px;
  border: 1px solid #e2e2df;
  border-radius: 14px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.12);
}

.model-menu[hidden] {
  display: none;
}

.model-menu button {
  display: grid;
  gap: 3px;
  border-radius: 10px;
  padding: 10px;
  background: transparent;
  color: #111;
  text-align: left;
}

.model-menu button:hover,
.model-menu button.active {
  background: #f3f3f1;
}

.model-menu strong {
  font-size: 14px;
  font-weight: 600;
}

.model-menu span {
  color: #777;
  font-size: 12px;
}

.voice-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  color: #111;
}

.voice-button:hover,
.voice-button.recording {
  background: #f2f2f0;
}

.voice-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.send-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 999px;
  background: #050505;
  color: #fff;
}

.send-button:disabled {
  opacity: 0.42;
}

.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.5;
}

.send-button .stop-icon {
  display: none;
}

.send-button.loading .send-icon {
  display: none;
}

.send-button.loading .stop-icon {
  display: block;
  stroke-width: 0;
  fill: currentColor;
}

.send-button .wave-icon {
  display: none;
}

.send-button.empty .send-icon {
  display: none;
}

.send-button.empty .wave-icon {
  display: block;
}

.scroll-bottom {
  position: fixed;
  left: calc(260px + (100vw - 260px) / 2);
  bottom: calc(var(--composer-height) + 42px);
  transform: translateX(-50%);
  z-index: 15;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #111;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.scroll-bottom svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.scroll-bottom:hover {
  background: #f7f7f5;
}

.console-page {
  position: fixed;
  inset: 0 0 0 260px;
  z-index: 18;
  overflow: auto;
  padding: 46px clamp(20px, 7vw, 120px) 64px;
  background: #fff;
  scrollbar-width: auto;
}

.console-open .conversation,
.console-open .welcome,
.console-open .composer-wrap {
  display: none;
}

.console-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  max-width: 1120px;
  align-items: flex-start;
  gap: 20px;
  margin: 0 auto 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #777;
  font-size: 13px;
}

.console-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
}

.metric-grid,
.console-layout {
  display: grid;
  max-width: 1120px;
  margin: 0 auto;
}

.console-tabs {
  display: flex;
  gap: 6px;
  max-width: 1120px;
  margin: 0 auto 18px;
  padding: 4px;
  border-bottom: 1px solid #ecece8;
  border-radius: 0;
  background: transparent;
}

.console-tabs button {
  height: 34px;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: #666;
}

.console-tabs button.active {
  background: #efefed;
  color: #111;
}

.console-tabs,
.metric-grid,
.console-layout {
  width: 100%;
}

.console-tab-panel {
  display: none;
}

.console-tab-panel.active {
  display: grid;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

body:not([data-console-tab="account"]) .metric-grid {
  display: none;
}

.metric-card,
.console-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.metric-card strong {
  overflow: hidden;
  font-size: 24px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.console-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

.console-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.console-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.usage-grid div {
  display: grid;
  gap: 6px;
  border: 1px solid #ededed;
  border-radius: 8px;
  padding: 12px;
}

.usage-grid strong {
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.api-section-title {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #ececea;
  color: #777;
  font-size: 12px;
  font-weight: 700;
}

.api-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.recharge-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.recharge-options button {
  height: 42px;
  border-radius: 8px;
  background: var(--surface-2);
  color: #111;
}

.recharge-options button:hover {
  background: #e7e7e4;
}

.status-pill {
  display: inline-flex;
  min-width: 58px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f4f4f4;
  color: #777;
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.ready {
  background: #ecf7ef;
  color: #1b7f3a;
}

.settings-row {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-row.compact {
  margin-top: 2px;
}

.memory-list {
  display: grid;
  gap: 8px;
}

.memory-empty,
.memory-item {
  border: 1px solid #ecece8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafafa;
  color: #5f5f5b;
  font-size: 14px;
  line-height: 1.5;
}

.memory-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  color: #20201d;
}

.memory-remove {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #777771;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.memory-remove:hover {
  background: #f1f1ef;
  color: #111;
}

.primary-button,
.secondary-button {
  height: 40px;
  border-radius: 999px;
  padding: 0 16px;
}

.primary-button {
  background: #111;
  color: #fff;
}

.secondary-button {
  background: var(--surface-2);
  color: #111;
}

.secondary-button:hover {
  background: #e8e8e5;
}

.wide {
  width: 100%;
}

.diagnose-output {
  max-height: 180px;
  overflow: auto;
  border: 1px solid #e5e5e3;
  border-radius: 8px;
  margin: 0;
  padding: 10px;
  background: #fafafa;
  color: #333;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.artifact-modal {
  position: fixed;
  inset: 0;
  z-index: 38;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.24);
}

.artifact-modal[hidden] {
  display: none !important;
}

.artifact-shell {
  display: grid;
  width: min(1080px, 100%);
  height: min(760px, calc(100vh - 44px));
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid #deded9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #ecece8;
  padding: 12px 14px 12px 18px;
}

.artifact-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.artifact-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.artifact-body {
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.artifact-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.artifact-document {
  width: min(780px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.artifact-text {
  margin: 0;
  min-height: 100%;
  padding: 18px;
  background: #fff;
  color: #111;
  font: 13px/1.6 Consolas, "SFMono-Regular", Menlo, monospace;
  white-space: pre-wrap;
}

.artifact-footer {
  display: flex;
  justify-content: center;
  gap: 6px;
  border-top: 1px solid #ecece8;
  padding: 8px;
  background: #fff;
}

.artifact-tab {
  min-width: 76px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: #666;
}

.artifact-tab.active {
  background: #f1f1ef;
  color: #111;
}

.artifact-tab:disabled {
  display: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  border-radius: 999px;
  padding: 10px 14px;
  background: #111;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 52px minmax(0, 1fr);
}

.sidebar-collapsed .sidebar {
  align-items: center;
  border-right-color: #f0f0ee;
}

.sidebar-collapsed .sidebar-header {
  width: 100%;
  height: auto;
  flex-direction: column;
  gap: 8px;
  padding: 14px 8px 8px;
}

.sidebar-collapsed .brand-button,
.sidebar-collapsed .nav-item,
.sidebar-collapsed .profile-card,
.sidebar-collapsed .sidebar-toggle {
  width: 34px;
  height: 34px;
  justify-content: center;
  border-radius: 10px;
  padding: 0;
}

.sidebar-collapsed .brand-button span,
.sidebar-collapsed .brand-button svg,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .profile-meta,
.sidebar-collapsed .profile-more,
.sidebar-collapsed .recent-panel {
  display: none;
}

.sidebar-collapsed .brand-button::before {
  content: "+";
  color: #111;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.sidebar-collapsed .nav-list {
  width: 100%;
  justify-items: center;
  gap: 8px;
  padding: 8px 0;
}

.sidebar-collapsed .nav-item.active {
  background: #f1f1ef;
}

.sidebar-collapsed .profile-card {
  margin: auto 0 14px;
}

.sidebar-collapsed .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.sidebar-collapsed .floating-sidebar {
  display: none;
}

.sidebar-collapsed .composer-wrap {
  left: 52px;
}

.sidebar-collapsed .console-page {
  left: 52px;
}

.sidebar-collapsed .scroll-bottom {
  left: calc(50% + 26px);
}

.sidebar-collapsed .conversation {
  width: min(900px, calc(100vw - 52px));
}

@media (max-width: 900px) {
  .metric-grid,
  .console-layout,
  .api-grid,
  .story-template-grid {
    grid-template-columns: 1fr;
  }

  .usage-card,
  .api-card {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  body.mobile-sidebar-open {
    overflow: hidden;
  }

  body.mobile-sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 23;
    background: rgba(0, 0, 0, 0.22);
  }

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

  .sidebar-collapsed .app-shell {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    inset: 0 auto 0 0;
    z-index: 24;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    visibility: visible;
    pointer-events: auto;
    box-shadow: 18px 0 50px rgba(0, 0, 0, 0.14);
  }

  .sidebar-collapsed .sidebar {
    align-items: stretch;
    border-right-color: #ececec;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .sidebar-collapsed .sidebar-header {
    width: auto;
    height: 52px;
    flex-direction: row;
    gap: 0;
    padding: max(8px, env(safe-area-inset-top)) 10px 6px 12px;
  }

  .sidebar-collapsed .brand-button,
  .sidebar-collapsed .nav-item,
  .sidebar-collapsed .profile-card,
  .sidebar-collapsed .sidebar-toggle {
    width: auto;
    height: auto;
    justify-content: flex-start;
    padding: 0;
  }

  .sidebar-collapsed .brand-button {
    width: auto;
    height: 36px;
    padding: 0 9px;
  }

  .sidebar-collapsed .nav-item {
    min-height: 36px;
    padding: 0 10px;
  }

  .sidebar-collapsed .sidebar-toggle {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
  }

  .sidebar-collapsed .brand-button span,
  .sidebar-collapsed .brand-button svg,
  .sidebar-collapsed .nav-item span,
  .sidebar-collapsed .profile-meta,
  .sidebar-collapsed .profile-more,
  .sidebar-collapsed .recent-panel {
    display: initial;
  }

  .sidebar-collapsed .recent-panel {
    display: block;
  }

  .sidebar-collapsed .brand-button::before {
    content: none;
  }

  .sidebar-collapsed .nav-list {
    width: auto;
    justify-items: stretch;
    gap: 1px;
    padding: 2px 8px 12px;
  }

  .sidebar-collapsed .profile-card {
    display: grid;
    width: auto;
    height: auto;
    margin: 0 8px 8px;
    padding: 8px;
  }

  .sidebar-collapsed .avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .sidebar-collapsed .composer-wrap,
  .sidebar-collapsed .console-page {
    left: 0;
  }

  .sidebar-collapsed .scroll-bottom {
    left: 50%;
  }

  .sidebar-collapsed .conversation {
    width: 100%;
  }

  .floating-sidebar {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    background: rgba(247, 247, 245, 0.92);
    backdrop-filter: blur(10px);
  }

  .composer-wrap {
    left: 0;
    top: calc(28% + 68px);
    padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
  }

  .scroll-bottom {
    left: 50%;
    bottom: calc(var(--composer-height) + max(26px, env(safe-area-inset-bottom) + 18px));
  }

  .has-messages .composer-wrap {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .conversation {
    width: 100%;
    padding: max(64px, env(safe-area-inset-top) + 52px) 16px calc(var(--composer-height) + 110px);
  }

  .message {
    margin: 14px 0;
  }

  .message.assistant .markdown-body {
    width: 100%;
  }

  .bubble {
    max-width: min(86vw, 100%);
  }

  .welcome {
    top: 28%;
    width: calc(100vw - 32px);
  }

  .welcome h1 {
    font-size: 24px;
  }

  .story-panel {
    width: 100%;
    min-height: 100dvh;
    padding: max(64px, env(safe-area-inset-top) + 52px) 16px 120px;
  }

  .story-panel header {
    align-items: center;
  }

  .console-page {
    left: 0;
    padding: max(24px, env(safe-area-inset-top) + 16px) 16px calc(36px + env(safe-area-inset-bottom));
  }

  .console-tabs {
    overflow-x: auto;
    justify-content: flex-start;
    margin-bottom: 14px;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .console-tabs button {
    flex: 0 0 auto;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .api-grid {
    grid-template-columns: 1fr;
  }

  .story-template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-background-grid {
    grid-template-columns: 1fr;
  }

  .story-background-modal {
    align-items: end;
    padding: 12px;
  }

  .story-background-card {
    width: 100%;
    max-height: min(86dvh, 760px);
    overflow: auto;
    border-radius: 20px;
    padding: 18px;
  }

  .artifact-modal {
    padding: 10px;
  }

  .artifact-shell {
    width: 100%;
    height: calc(100dvh - 20px);
    border-radius: 16px;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    align-items: start;
    padding: max(64px, env(safe-area-inset-top) + 42px) 22px 28px;
  }

  .auth-panel {
    gap: 20px;
  }

  .auth-brand {
    align-items: flex-start;
  }

  .auth-brand h1 {
    font-size: 24px;
  }

  .auth-brand p {
    font-size: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .nav-item,
  .history-item,
  .profile-card {
    min-height: 42px;
  }

  .history-delete {
    opacity: 1;
    pointer-events: auto;
  }

  .conversation {
    padding-inline: 14px;
  }

  .bubble {
    border-radius: 20px;
    padding: 10px 13px;
    line-height: 1.6;
  }

  .message.user .bubble {
    max-width: min(84vw, 100%);
  }

  .markdown-body {
    font-size: 15.5px;
  }

  .markdown-body h2 {
    font-size: 18px;
  }

  .markdown-body h3 {
    font-size: 16px;
  }

  .markdown-body table {
    font-size: 13px;
  }

  .code-toolbar {
    height: 36px;
    padding: 0 10px;
  }

  .markdown-body .code-block code {
    padding: 12px;
    font-size: 12.5px;
  }

  .artifact-tray,
  .generated-image-grid {
    width: 100%;
  }

  .artifact-card {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    min-height: 62px;
    padding: 8px;
  }

  .artifact-card-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .artifact-card-open {
    padding: 6px 9px;
    font-size: 12px;
  }

  .generated-image-card {
    border-radius: 24px;
  }

  .image-preview-modal {
    place-items: start center;
    padding: 54px 14px 56px;
  }

  .image-preview-shell {
    width: 100%;
    height: min(58dvh, 460px);
    transform: translateY(-10px);
  }

  .image-preview-shell img {
    border-radius: 18px;
  }

  .image-preview-actions {
    top: -46px;
    right: 0;
  }

  .attachment-tray {
    max-width: 100%;
  }

  .message-actions {
    opacity: 1;
  }

  .user-edit-form {
    width: min(100%, 84vw);
  }

  .composer {
    width: 100%;
    min-height: 54px;
    border-radius: 27px;
    padding: 10px 8px 8px 14px;
  }

  .composer.has-attachments {
    border-radius: 24px;
  }

  .attachment-list {
    gap: 8px;
    max-height: 160px;
    overflow: auto;
    padding-right: 2px;
  }

  .attachment-pill {
    width: 100%;
    max-width: 100%;
  }

  .attachment-pill.image-pill {
    width: 100%;
    min-width: 0;
  }

  .composer-footer {
    grid-template-columns: 32px minmax(0, 1fr) auto 34px 36px;
    gap: 5px;
  }

  .composer-tool {
    width: 32px;
    height: 32px;
  }

  .model-pill {
    height: 34px;
    max-width: 70px;
    padding: 0 9px;
    overflow: hidden;
    font-size: 13px;
  }

  .voice-button {
    width: 34px;
    height: 34px;
  }

  .send-button {
    width: 36px;
    height: 36px;
  }

  .model-menu {
    right: max(8px, env(safe-area-inset-right));
    bottom: 48px;
    width: min(232px, calc(100vw - 28px));
  }

  .console-header {
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }

  .console-header h1 {
    font-size: 24px;
  }

  .console-header p:not(.eyebrow) {
    font-size: 13px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card,
  .console-card {
    border-radius: 10px;
  }

  .metric-card {
    padding: 11px;
  }

  .metric-card strong {
    font-size: 19px;
  }

  .console-card {
    gap: 12px;
    padding: 14px;
  }

  .usage-grid,
  .recharge-options {
    grid-template-columns: 1fr;
  }

  .settings-row {
    justify-content: flex-end;
  }

  .settings-row .primary-button,
  .settings-row .secondary-button {
    flex: 0 1 auto;
  }

  .console-card > .primary-button {
    width: 100%;
  }

  .story-panel {
    padding-inline: 14px;
  }

  .story-panel header {
    gap: 10px;
  }

  .story-panel h2 {
    font-size: 20px;
  }

  .story-template-grid {
    gap: 8px;
  }

  .story-template-grid button {
    min-height: 112px;
    padding: 11px;
  }

  .story-background-card {
    padding: 16px;
  }

  .story-background-card header {
    gap: 10px;
  }

  .story-background-card h2 {
    font-size: 18px;
  }

  .story-background-subtitle {
    font-size: 12px;
  }

  .story-background-grid textarea {
    min-height: 86px;
  }

  .artifact-header {
    align-items: flex-start;
    padding: 10px 10px 10px 14px;
  }

  .artifact-header h2 {
    max-width: 42vw;
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .artifact-actions {
    gap: 5px;
  }

  .artifact-actions .mini {
    padding: 0 9px;
  }

  .artifact-document {
    width: calc(100% - 24px);
    padding: 20px 0 36px;
  }

  .artifact-text {
    padding: 12px;
    font-size: 12px;
  }

  .toast {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 420px) {
  .story-template-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .composer-footer {
    grid-template-columns: 30px minmax(0, 1fr) 58px 32px 34px;
  }

  .model-pill {
    max-width: 58px;
    padding: 0 7px;
  }

  .settings-row {
    justify-content: stretch;
  }

  .settings-row .primary-button,
  .settings-row .secondary-button {
    flex: 1 1 auto;
  }

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

  .artifact-card-open {
    grid-column: 1 / -1;
    justify-self: end;
  }
}
