:root {
  --bg: #080b16;
  --bg-soft: #101827;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.13);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef2ff;
  --muted: #aab3cc;
  --muted-2: #78839d;
  --brand: #72e5ff;
  --brand-2: #8b5cf6;
  --brand-3: #f59e0b;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar: 320px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 8%, rgba(114, 229, 255, 0.20), transparent 32rem),
    radial-gradient(circle at 78% 14%, rgba(139, 92, 246, 0.28), transparent 34rem),
    radial-gradient(circle at 76% 88%, rgba(245, 158, 11, 0.18), transparent 30rem),
    linear-gradient(135deg, #070913 0%, #0d1224 58%, #111827 100%);
  background-attachment: fixed;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.boot-screen h1 {
  margin: 0 0 8px;
  font-size: 34px;
}

.boot-screen p {
  margin: 0;
  color: var(--muted);
}

.brand-orb,
.logo-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  font-size: 25px;
  font-weight: 900;
  color: white;
  background:
    radial-gradient(circle at 68% 22%, rgba(255, 255, 255, 0.92), transparent 0.42rem),
    linear-gradient(135deg, var(--brand), var(--brand-2) 56%, var(--brand-3));
  box-shadow: 0 18px 45px rgba(90, 121, 255, 0.42);
}

.logo-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  font-size: 20px;
}

.landing {
  min-height: 100vh;
  padding: 26px;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 13, 27, 0.62);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand-line,
.user-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand-subtitle,
.user-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 430px;
  gap: 28px;
  align-items: stretch;
}

.hero-card,
.auth-card,
.panel-card,
.message-composer,
.chat-empty,
.paywall,
.admin-shell,
.sidebar,
.workspace {
  border: 1px solid var(--line);
  background: rgba(10, 16, 33, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 640px;
  border-radius: var(--radius-xl);
  padding: 54px;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(114, 229, 255, 0.34), transparent 64%);
  pointer-events: none;
}

.hero-kicker,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #dff8ff;
  background: rgba(114, 229, 255, 0.10);
  border: 1px solid rgba(114, 229, 255, 0.25);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.hero-card h1 {
  position: relative;
  margin: 26px 0 20px;
  max-width: 780px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.gradient-text {
  background: linear-gradient(120deg, #fff, #8beaff 30%, #c4b5fd 65%, #fef3c7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lead {
  position: relative;
  max-width: 700px;
  color: #c9d3ea;
  line-height: 1.8;
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 30px 0;
}

.feature-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 36px;
}

.feature-item,
.stat-card,
.plan-card,
.order-card,
.setting-group,
.prompt-card,
.audit-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-lg);
}

.feature-item {
  padding: 18px;
}

.feature-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(114, 229, 255, 0.20), rgba(139, 92, 246, 0.24));
}

.feature-item h3,
.plan-card h3,
.panel-card h3,
.setting-group h3 {
  margin: 0 0 8px;
}

.feature-item p,
.plan-card p,
.panel-card p,
.setting-group p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.auth-card {
  border-radius: var(--radius-xl);
  padding: 26px;
  align-self: stretch;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
}

.auth-tab {
  cursor: pointer;
  padding: 12px;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
}

.auth-tab.active {
  color: white;
  background: linear-gradient(135deg, rgba(114, 229, 255, 0.18), rgba(139, 92, 246, 0.30));
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.auth-note {
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 20px;
}

.form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #d7ddef;
  font-size: 13px;
  font-weight: 700;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  color: var(--text);
  background: rgba(5, 9, 18, 0.70);
  outline: none;
  padding: 13px 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.65;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(114, 229, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(114, 229, 255, 0.10);
  background: rgba(7, 12, 24, 0.9);
}

.select option {
  background: #101827;
  color: white;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 17px;
  border-radius: 14px;
  cursor: pointer;
  color: white;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.btn.primary {
  border: 0;
  background: linear-gradient(135deg, #37d4f6, #7c3aed 58%, #f59e0b);
  box-shadow: 0 18px 38px rgba(93, 93, 255, 0.35);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.30);
}

.btn.success {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.30);
}

.btn.full {
  width: 100%;
}

.btn.small {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 11px;
  font-size: 13px;
}

.micro-copy {
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.55;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-head {
  padding: 20px 18px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-actions {
  padding: 0 18px 14px;
}

.side-nav {
  padding: 0 12px 14px;
  display: grid;
  gap: 6px;
}

.side-link {
  width: 100%;
  justify-content: flex-start;
  color: #dbe4f7;
  background: transparent;
}

.side-link.active {
  background: rgba(114, 229, 255, 0.13);
  border-color: rgba(114, 229, 255, 0.24);
}

.sidebar-section-title {
  padding: 14px 18px 8px;
  font-size: 12px;
  color: var(--muted-2);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 14px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 10px 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.chat-item:hover,
.chat-item.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.chat-meta {
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.10);
}

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.user-card {
  border-radius: 20px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.user-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-quota {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
}

.user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.admin-user-create {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(114, 229, 255, 0.30), rgba(139, 92, 246, 0.35));
}

.workspace {
  min-height: calc(100vh - 32px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(5, 9, 18, 0.30);
}

.topbar-title h2 {
  margin: 0;
  font-size: 20px;
}

.topbar-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions:empty {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.08);
  color: #e8edff;
}

.badge.ok {
  color: #a7f3d0;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.12);
}

.badge.warn,
.badge.pending {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.30);
  background: rgba(251, 191, 36, 0.12);
}

.badge.bad,
.badge.rejected {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.30);
  background: rgba(251, 113, 133, 0.12);
}

.main-panel {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.chat-view {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.messages {
  overflow-y: auto;
  padding: 18px 24px 22px;
  scroll-behavior: smooth;
}

.welcome-card {
  max-width: 860px;
  margin: 10px auto 18px;
  padding: 18px 2px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.welcome-card h2 {
  margin: 8px 0 6px;
  font-size: 24px;
}

.welcome-card p {
  color: var(--muted);
  line-height: 1.75;
  margin: 0;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.prompt-card {
  text-align: left;
  color: #edf2ff;
  padding: 12px;
  cursor: pointer;
  border-radius: 14px;
}

.prompt-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.10);
}

.prompt-card strong {
  display: block;
  margin-bottom: 6px;
}

.prompt-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.message {
  max-width: 840px;
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 13px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 42px;
  margin-left: auto;
  margin-right: auto;
}

.message.user .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.user .message-body {
  grid-column: 1;
  grid-row: 1;
  text-align: right;
}

.message-avatar {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.10);
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, rgba(114, 229, 255, 0.28), rgba(139, 92, 246, 0.32));
}

.message.user .message-avatar {
  background: rgba(245, 158, 11, 0.18);
}

.message-body {
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 0 8px;
  color: #dbe6fb;
  border-bottom: 0;
  font-size: 13px;
}

.message.user .message-head {
  align-items: flex-end;
  justify-content: flex-end;
}

.message-head-main {
  display: grid;
  gap: 3px;
}

.message-name {
  color: #eef4ff;
  font-weight: 800;
}

.message-meta {
  display: block;
}

.message-content {
  padding: 0;
  line-height: 1.82;
  color: #f1f5ff;
  word-break: break-word;
}

.message-content.compact {
  padding: 12px 0 0;
}

.message-content pre {
  margin: 12px 0;
  overflow-x: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.message-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.composer-wrap {
  padding: 16px 24px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(5, 9, 18, 0.42);
}

.message-composer {
  max-width: 930px;
  margin: 0 auto;
  border-radius: 24px;
  padding: 12px;
  min-width: 0;
  position: relative;
}

.message-composer.is-dragging {
  background: rgba(56, 189, 248, 0.08);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.46), 0 20px 48px rgba(14, 165, 233, 0.12);
}

.composer-drop-hint {
  pointer-events: none;
  position: absolute;
  inset: 8px;
  z-index: 8;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(125, 211, 252, 0.78);
  border-radius: 18px;
  color: #dff7ff;
  background: rgba(7, 12, 24, 0.74);
  opacity: 0;
  transform: scale(0.99);
  transition: opacity 0.16s ease, transform 0.16s ease;
  font-size: 14px;
  font-weight: 800;
}

.message-composer.is-dragging .composer-drop-hint {
  opacity: 1;
  transform: scale(1);
}

.composer-textarea {
  width: 100%;
  min-height: 70px;
  max-height: 220px;
  resize: none;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  padding: 8px;
  line-height: 1.6;
  overflow-y: hidden;
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px;
  min-width: 0;
  max-width: 100%;
}

.composer-tool-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.composer-tool-row-right {
  justify-content: flex-end;
  flex-wrap: nowrap;
  margin-left: auto;
}

.send-icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(93, 93, 255, 0.28);
  display: inline-grid;
  place-items: center;
}

.send-icon-btn span {
  display: block;
  transform: translateY(-1px);
}

.send-icon-btn.is-loading {
  cursor: wait;
  opacity: .92;
}

.send-icon-btn.is-loading .send-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(7, 17, 31, 0.28);
  border-top-color: #07111f;
  border-radius: 999px;
  transform: none;
  animation: sendSpin .72s linear infinite;
}

@keyframes sendSpin {
  to {
    transform: rotate(360deg);
  }
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.mode-pill {
  cursor: pointer;
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.mode-pill.active {
  color: #07111f;
  background: #f7fbff;
}

.tool-pill,
.tool-select {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.tool-pill {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  font-weight: 700;
}

.composer-tools:not(.image-mode-active) .image-only-tools,
.composer-tools:not(.image-mode-active) .image-settings-menu {
  display: none;
}

.composer-mode-row {
  flex: 0 0 auto;
}

.file-tool input {
  display: none;
}

.file-tool {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  justify-content: center;
  gap: 0;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(233, 242, 255, 0.76);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0;
  font-weight: 500;
  line-height: 1;
}

.file-tool span {
  width: 0;
  height: 0;
  overflow: hidden;
  font-size: 0;
}

.file-tool::before {
  content: "+";
  font-size: 21px;
  line-height: 1;
  transform: translateY(-1px);
}

.upload-actions {
  align-items: stretch;
}

.upload-card input {
  display: none;
}

.upload-card {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 176px;
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid rgba(114, 229, 255, 0.24);
  border-radius: 8px;
  color: #eef8ff;
  background: linear-gradient(180deg, rgba(21, 31, 43, 0.98), rgba(11, 17, 27, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.upload-card:hover,
.upload-card:focus-within {
  border-color: rgba(114, 229, 255, 0.56);
  background: linear-gradient(180deg, rgba(26, 41, 55, 0.98), rgba(14, 23, 35, 0.98));
}

.upload-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 34px;
  border-radius: 6px;
  color: #07111f;
  background: #8ee9ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.upload-card-pdf .upload-card-icon {
  background: #ffd28a;
}

.upload-card-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  line-height: 1.15;
}

.upload-card-copy strong {
  display: block;
  color: #f8fbff;
  font-size: 14px;
  font-weight: 850;
}

.upload-card-copy small {
  display: block;
  color: rgba(216, 230, 244, 0.70);
  font-size: 12px;
  font-weight: 650;
}

.tool-select {
  cursor: pointer;
  max-width: 128px;
  padding: 0 30px 0 12px;
  outline: none;
}

.image-settings-menu {
  position: relative;
  flex: 0 0 auto;
  width: max-content;
}

.image-settings-menu summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

.image-settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: grid;
  gap: 8px;
  width: min(308px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.image-setting-group {
  display: grid;
  gap: 6px;
}

.image-setting-group[aria-label="图片比例"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.image-setting-group[aria-label="图片数量"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-count-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.image-option {
  appearance: none;
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 4px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.image-option:hover,
.image-option:focus-visible {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
}

.image-option.active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.ratio-icon {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: .86;
}

.ratio-auto {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
}

.ratio-auto::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: currentColor;
  opacity: .38;
}

.ratio-16-9 {
  width: 22px;
  height: 13px;
}

.ratio-4-3 {
  width: 20px;
  height: 15px;
}

.ratio-1-1 {
  width: 17px;
  height: 17px;
}

.ratio-2-3 {
  width: 14px;
  height: 21px;
}

.ratio-3-4 {
  width: 15px;
  height: 20px;
}

.ratio-9-16 {
  width: 13px;
  height: 22px;
}

.tool-select option {
  background: #101827;
  color: white;
}

.tool-pill:hover,
.file-tool:hover,
.tool-select:hover,
.tool-select:focus,
.image-settings-menu summary:hover {
  border-color: rgba(114, 229, 255, 0.42);
  background: rgba(114, 229, 255, 0.10);
}

.upload-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 8px;
}

.upload-preview {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  overflow: visible;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  object-fit: cover;
}

.pdf-upload-preview {
  width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px 8px 8px;
  overflow: hidden;
}

.pdf-file-icon {
  flex: 0 0 auto;
  padding: 3px 5px;
  border-radius: 5px;
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.pdf-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e5e7eb;
  font-size: 12px;
}

.upload-remove-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.20);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.upload-remove-btn:hover {
  background: rgba(239, 68, 68, 0.96);
  border-color: rgba(254, 202, 202, 0.62);
}

.image-caption {
  margin: 8px 4px 0;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.chat-empty,
.paywall {
  max-width: 820px;
  margin: 46px auto;
  border-radius: var(--radius-xl);
  padding: 34px;
  text-align: center;
}

.chat-empty h2,
.paywall h2 {
  margin: 16px 0 8px;
  font-size: 30px;
}

.chat-empty p,
.paywall p {
  margin: 0 auto 22px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 620px;
}

.content-scroll {
  height: 100%;
  overflow: auto;
  padding: 24px;
}

.page-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.panel-card {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.card-head h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.stats-grid,
.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stats-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  padding: 18px;
}

.stat-value {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 4px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.plan-card {
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.plan-card.selected {
  border-color: rgba(114, 229, 255, 0.45);
  box-shadow: inset 0 0 0 1px rgba(114, 229, 255, 0.25);
}

.plan-price {
  font-size: 34px;
  font-weight: 900;
  margin: 16px 0 8px;
}

.plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.payment-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: stretch;
}

.qr-box {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 22px;
  padding: 18px;
  color: #dce7fb;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.055) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.055) 50%, rgba(255,255,255,0.055) 75%, transparent 75%),
    rgba(255, 255, 255, 0.07);
  background-size: 26px 26px;
  border: 1px dashed rgba(255, 255, 255, 0.20);
  line-height: 1.65;
}

.qr-box img {
  max-width: 100%;
  max-height: 230px;
  border-radius: 18px;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
}

th {
  color: #dbe5fa;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
}

td {
  color: #f0f4ff;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.log-detail {
  max-width: 620px;
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
  color: #dbeafe;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.admin-tab.active {
  background: rgba(114, 229, 255, 0.14);
  border-color: rgba(114, 229, 255, 0.28);
}

.admin-section {
  display: grid;
  gap: 16px;
}

.order-actions {
  display: grid;
  grid-template-columns: 90px 100px minmax(180px, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-actions {
  justify-content: flex-end;
  padding-top: 2px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setting-group {
  padding: 18px;
}

.setting-group.wide {
  grid-column: 1 / -1;
}

.plan-editor {
  display: grid;
  gap: 12px;
}

.plan-row {
  display: grid;
  grid-template-columns: 0.8fr 1fr 0.7fr 0.7fr 0.8fr 1.4fr;
  gap: 8px;
}

.api-test-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.api-test-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
}

.api-test-actions .btn,
.settings-actions .btn {
  min-width: max-content;
}

.test-output {
  min-height: 120px;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #e8efff;
  padding: 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.empty-note,
.loading-note {
  padding: 22px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.loading-dots::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dots 1.1s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99;
  display: grid;
  gap: 10px;
  max-width: min(420px, calc(100vw - 44px));
}

.toast-item {
  padding: 13px 15px;
  border-radius: 16px;
  color: white;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: toast-in 0.18s ease-out;
}

.toast-item.ok {
  border-color: rgba(52, 211, 153, 0.34);
}

.toast-item.bad {
  border-color: rgba(251, 113, 133, 0.36);
}

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes wait-sweep {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(100%); }
}

@keyframes gradient-flow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes image-tile-pulse {
  0%, 100% { opacity: 0.56; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.mobile-menu {
  display: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .landing-grid,
  .payment-box,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .stats-grid.four,
  .plans-grid,
  .feature-grid,
  .prompt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

  .chat-list {
    max-height: 260px;
  }
}

@media (max-width: 720px) {
  .landing,
  .shell,
  .content-scroll,
  .messages,
  .composer-wrap {
    padding: 14px;
  }

  .landing-nav,
  .topbar,
  .card-head,
  .user-card-row {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 24px;
  }

  .nav-actions,
  .topbar-actions,
  .hero-actions,
  .inline-actions {
    width: 100%;
  }

  .nav-actions .btn,
  .topbar-actions .btn,
  .hero-actions .btn {
    flex: 1;
  }

  .hero-card {
    padding: 28px;
    min-height: auto;
  }

  .auth-card,
  .panel-card,
  .chat-empty,
  .paywall {
    padding: 20px;
  }

  .form-row,
  .stats-grid,
  .stats-grid.four,
  .plans-grid,
  .feature-grid,
  .prompt-grid,
  .order-actions,
  .api-test-row,
  .plan-row {
    grid-template-columns: 1fr;
  }

  .api-test-actions,
  .settings-actions {
    width: 100%;
  }

  .api-test-actions .btn,
  .settings-actions .btn {
    flex: 1;
  }

  .composer-tools {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 4px;
  }

  .composer-tool-row,
  .composer-tools .inline-actions {
    width: 100%;
  }

  .composer-tools .inline-actions {
    justify-content: flex-end;
  }

  .progress-wait-note {
    display: grid;
    gap: 4px;
  }

  .message {
    grid-template-columns: 1fr;
  }

  .message-avatar {
    display: none;
  }
}

/* 增强：导航说明、会话状态、图文结果与导出 */
.side-link {
  min-height: 58px;
  align-items: center;
  gap: 10px;
  white-space: normal;
}

.side-icon {
  flex: 0 0 auto;
  width: 28px;
  text-align: center;
}

.side-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.side-text strong {
  font-size: 14px;
  line-height: 1.25;
}

.side-text small {
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.35;
}

.chat-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.chat-title-row .badge {
  min-height: 22px;
  padding: 0 7px;
  font-size: 10px;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 14px;
}

.notice-card {
  margin: 14px 14px 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.065);
  color: #eef4ff;
}

.notice-card.warn {
  border-color: rgba(251, 191, 36, 0.34);
  background: rgba(251, 191, 36, 0.10);
}

.notice-card.bad {
  border-color: rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.10);
}

.notice-card.ok {
  border-color: rgba(52, 211, 153, 0.34);
  background: rgba(52, 211, 153, 0.10);
}

.notice-card.info {
  border-color: rgba(114, 229, 255, 0.26);
  background: rgba(114, 229, 255, 0.08);
}

.notice-title {
  font-weight: 900;
  margin-bottom: 6px;
}

.notice-subtitle {
  margin-top: 10px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 900;
}

.notice-card p {
  margin: 0;
  color: #dbe5fa;
  line-height: 1.7;
}

.notice-card ul {
  margin: 6px 0 0 18px;
  padding: 0;
  color: #dbe5fa;
  line-height: 1.7;
}

.diagnostic-box {
  margin: 0 14px 14px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.20);
  overflow: hidden;
}

.diagnostic-box summary {
  cursor: pointer;
  padding: 11px 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 13px 12px;
}

.diagnostic-grid div {
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.06);
}

.diagnostic-grid span {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
  margin-bottom: 4px;
}

.diagnostic-grid strong {
  font-size: 12px;
  word-break: break-all;
}

.diagnostic-box pre {
  margin: 0 13px 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d1d9ee;
  font-size: 12px;
  line-height: 1.6;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.30);
}

.image-results-wrap {
  display: grid;
  gap: 10px;
}

.image-batch-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
}

.image-batch-count {
  color: var(--muted-2);
  font-size: 13px;
}

.image-results {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}

.file-results {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.file-asset-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
}

.file-asset-icon {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(122, 31, 22, 0.92), rgba(154, 124, 53, 0.72));
  letter-spacing: 0;
}

.file-asset-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.file-asset-main strong,
.file-asset-main span,
.file-asset-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-asset-main strong {
  color: #f8fbff;
  font-size: 14px;
}

.file-asset-main span {
  color: var(--muted);
  font-size: 12px;
}

.file-asset-main small {
  color: var(--muted-2);
  font-size: 11px;
}

.message.assistant.image-focused {
  max-width: 840px;
}

.message.assistant.image-focused .message-body {
  border: 0;
  border-radius: 0;
  background: transparent;
  max-width: min(700px, 100%);
}

.message.image-focused .message-head {
  border-bottom: 0;
  padding: 4px 2px 10px;
  color: var(--muted);
}

.message.image-focused .image-results {
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 340px));
  justify-content: start;
  justify-items: start;
  padding: 0;
  gap: 14px;
}

.message.image-focused .image-results:has(.image-card:only-child) {
  grid-template-columns: minmax(0, 340px);
}

.image-card {
  margin: 0;
  width: min(340px, 100%);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.message.image-focused .image-card {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-stage {
  width: 100%;
  border: 0;
  cursor: zoom-in;
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: transparent;
}

.message.image-focused .image-stage {
  min-height: clamp(180px, 32vh, 300px);
  background: transparent;
}

.image-card[data-orientation="portrait"] .image-stage {
  min-height: clamp(280px, 52vh, 520px);
}

.image-card[data-orientation="landscape"] .image-stage {
  min-height: clamp(180px, 30vh, 300px);
}

.image-stage:hover img {
  transform: scale(1.01);
}

.image-stage img {
  display: block;
  max-width: 100%;
  max-height: 680px;
  object-fit: contain;
  transition: transform 0.16s ease;
}

.message.image-focused .image-stage img {
  max-height: clamp(190px, 34vh, 320px);
}

.message.image-focused .image-card[data-orientation="portrait"] .image-stage img {
  max-height: clamp(300px, 54vh, 540px);
}

.message.image-focused .image-card[data-orientation="landscape"] .image-stage img {
  max-height: clamp(190px, 34vh, 320px);
}

.image-card figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.message.image-focused .image-card figcaption {
  padding: 10px 12px;
  background: rgba(2, 6, 23, 0.28);
}

.image-message-details {
  margin: 0 0 12px;
  max-width: min(520px, 100%);
}

.image-message-details summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.image-message-details summary::-webkit-details-marker {
  display: none;
}

.image-message-details[open] summary {
  margin-bottom: 10px;
}

.image-message-details > .message-content,
.image-message-details > .diagnostic-box,
.image-message-details > .image-details-empty,
.image-message-details > .message-actions {
  max-width: min(520px, 100%);
}

.image-details-empty {
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.7;
}

.image-message-details > .message-actions {
  padding: 8px 0 0;
}

.image-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 8px;
}

.image-card figcaption strong,
.image-card figcaption span {
  display: block;
}

.image-card figcaption span {
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 3px;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(18px);
}

.image-preview-dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  background: rgba(8, 13, 25, 0.96);
  box-shadow: var(--shadow);
}

.image-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.image-preview-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-body {
  display: grid;
  place-items: center;
  max-height: calc(92vh - 54px);
  padding: 14px;
}

.image-preview-body img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 82px);
  object-fit: contain;
  border-radius: 12px;
}

.message.has-assets {
  max-width: 840px;
}

.cover-brief-box {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 16px;
  color: #dbeafe;
  background: rgba(114, 229, 255, 0.08);
  border: 1px solid rgba(114, 229, 255, 0.20);
  line-height: 1.7;
}

.prompt-card.featured {
  border-color: rgba(114, 229, 255, 0.30);
  background: linear-gradient(135deg, rgba(114, 229, 255, 0.12), rgba(139, 92, 246, 0.14));
}

.progress-card {
  padding: 16px;
}

.image-progress-card {
  position: relative;
  overflow: hidden;
}

.image-progress-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 0%, rgba(114, 229, 255, 0.08) 42%, transparent 70%);
  transform: translateX(-100%);
  animation: wait-sweep 2.4s ease-in-out infinite;
}

.progress-title {
  position: relative;
  color: #dbeafe;
  margin-bottom: 12px;
}

.progress-title strong {
  color: #f8fbff;
}

.progress-wait-note {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.6;
}

.progress-wait-note strong {
  color: #dbeafe;
}

.progressbar {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.progressbar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand-3));
  transition: width 0.3s ease;
}

.image-progress-card .progressbar span {
  background-size: 200% 100%;
  animation: gradient-flow 1.4s linear infinite;
}

.image-wait-preview {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.image-wait-preview span {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background:
    linear-gradient(135deg, rgba(114, 229, 255, 0.13), rgba(139, 92, 246, 0.08)),
    rgba(255, 255, 255, 0.045);
  animation: image-tile-pulse 1.6s ease-in-out infinite;
}

.image-wait-preview span:nth-child(2) { animation-delay: 0.16s; }
.image-wait-preview span:nth-child(3) { animation-delay: 0.32s; }
.image-wait-preview span:nth-child(4) { animation-delay: 0.48s; }

.image-wait-preview i {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--brand);
  animation: spin 0.9s linear infinite;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.progress-steps span {
  padding: 8px 9px;
  border-radius: 12px;
  color: var(--muted-2);
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
  line-height: 1.45;
}

.progress-steps span.done {
  color: #e8f7ff;
  background: rgba(114, 229, 255, 0.13);
}

.settings-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(114, 229, 255, 0.07);
  border: 1px solid rgba(114, 229, 255, 0.16);
}

.test-output {
  white-space: normal;
}

.test-answer {
  line-height: 1.8;
}

#printArea {
  display: none;
}

@page {
  size: A4;
  margin: 12mm;
}

@page pdf-image-portrait {
  size: A4 portrait;
  margin: 0;
}

@page pdf-image-landscape {
  size: A4 landscape;
  margin: 0;
}

@media print {
  body.print-mode > *:not(#printArea) {
    display: none !important;
  }

  body.print-mode #printArea {
    display: block !important;
  }

  body.print-mode {
    background: white !important;
    color: #111827 !important;
  }

  body.pdf-image-portrait .deliverable-print {
    page: pdf-image-portrait;
  }

  body.pdf-image-landscape .deliverable-print {
    page: pdf-image-landscape;
  }

  .print-page {
    color: #111827;
    font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    padding: 24px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .print-page.deliverable-print {
    padding: 0;
  }

  .print-page h1 {
    margin: 0 0 18px;
    font-size: 24px;
  }

  .print-message {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 16px;
    margin: 0 0 14px;
    background: white;
  }

  .print-meta {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 10px;
  }

  .print-content {
    line-height: 1.75;
  }

  .print-content pre,
  .print-message pre {
    white-space: pre-wrap;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    background: #f9fafb;
    color: #111827;
  }

  .print-image-results {
    display: grid;
    gap: 14px;
    padding-top: 12px;
  }

  .print-image-card {
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 0;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 12px;
    background: white;
  }

  .print-image-card + .print-image-card {
    break-before: page;
    page-break-before: always;
  }

  .print-image-stage {
    display: grid;
    place-items: center;
    min-height: 80mm;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8mm;
    background: #f9fafb;
  }

  .print-image-stage img {
    display: block;
    max-width: 100%;
    max-height: 180mm;
    object-fit: contain;
  }

  .print-image-card figcaption {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    color: #6b7280;
    font-size: 12px;
  }

  .print-image-card figcaption strong {
    color: #111827;
  }

  .print-message .image-results {
    padding: 12px 0 0;
  }

  .print-message .image-card {
    border-color: #d1d5db;
    background: white;
  }

  .print-message .image-stage {
    min-height: auto;
    background: white;
  }

  .print-message .image-stage img {
    max-height: 720px;
  }

  .print-message .image-card figcaption {
    color: #111827;
  }

  .deliverable-page {
    page-break-after: always;
    break-after: page;
    min-height: 258mm;
    color: #111827;
    background: white;
    font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .deliverable-page:last-child {
    page-break-after: auto;
  }

  .cover-sheet {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    padding: 34mm 24mm;
  }

  .deliverable-brand {
    color: #2563eb;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0;
  }

  .cover-sheet h1 {
    margin: 0;
    max-width: 150mm;
    font-size: 34px;
    line-height: 1.2;
  }

  .cover-sheet p {
    margin: 0;
    color: #4b5563;
    font-size: 16px;
  }

  .cover-sheet dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0 0;
  }

  .cover-sheet dt,
  .appendix-block h2 {
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
  }

  .cover-sheet dd {
    margin: 5px 0 0;
    font-size: 14px;
    font-weight: 800;
  }

  .image-sheet {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
    padding: 14mm;
  }

  .image-sheet header,
  .image-sheet footer,
  .appendix-sheet header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    color: #6b7280;
    font-size: 11px;
  }

  .image-sheet header strong,
  .appendix-sheet header strong {
    color: #111827;
    font-size: 15px;
  }

  .deliverable-image-frame {
    display: grid;
    place-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 10mm;
    background: #f9fafb;
  }

  .deliverable-image-frame img {
    display: block;
    max-width: 100%;
    max-height: 210mm;
    object-fit: contain;
    border-radius: 8px;
  }

  .pdf-page-image-sheet {
    display: grid;
    place-items: center;
    padding: 0;
    width: 210mm;
    min-height: 297mm;
    height: 297mm;
    background: white;
  }

  .image-only-pdf-page {
    width: 210mm;
    height: 297mm;
    overflow: hidden;
  }

  body.pdf-image-landscape .pdf-page-image-sheet,
  .image-only-landscape {
    width: 297mm;
    min-height: 210mm;
    height: 210mm;
  }

  .pdf-page-only-image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
  }

  body.pdf-image-landscape .pdf-page-only-image,
  .image-only-landscape .pdf-page-only-image {
    max-height: 100%;
  }

  .appendix-sheet {
    display: grid;
    align-content: start;
    gap: 16px;
    padding: 18mm;
  }

  .appendix-block {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
  }

  .appendix-block h2 {
    margin: 0 0 8px;
  }

  .appendix-block p {
    margin: 0;
    line-height: 1.75;
  }

  .appendix-block pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    line-height: 1.55;
  }

  .appendix-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .appendix-grid div {
    display: grid;
    gap: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
  }

  .appendix-grid span {
    color: #6b7280;
    font-size: 12px;
  }

  .book-cover-sheet,
  .book-toc-sheet,
  .book-chapter-sheet,
  .book-appendix-sheet {
    position: relative;
    padding: 18mm 18mm 20mm;
  }

  .book-cover-sheet footer,
  .book-toc-sheet footer,
  .book-chapter-sheet footer,
  .book-appendix-sheet footer {
    position: absolute;
    left: 18mm;
    right: 18mm;
    bottom: 8mm;
    border-top: 1px solid #e5e7eb;
    padding-top: 4mm;
    color: #6b7280;
    font-size: 10px;
    text-align: center;
  }

  .book-cover-sheet {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 16mm;
    align-items: center;
  }

  .book-cover-copy {
    display: grid;
    gap: 8mm;
  }

  .book-kicker {
    color: #2563eb;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .book-cover-sheet h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.18;
  }

  .book-cover-sheet p {
    margin: 0;
    color: #4b5563;
    font-size: 16px;
    line-height: 1.7;
  }

  .book-cover-image {
    width: 100%;
    max-height: 190mm;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
  }

  .book-toc-sheet header,
  .book-chapter-sheet header,
  .book-appendix-sheet header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10mm;
    color: #6b7280;
    font-size: 11px;
  }

  .book-toc-sheet header strong,
  .book-chapter-sheet header strong,
  .book-appendix-sheet header strong {
    color: #111827;
    font-size: 15px;
  }

  .book-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10mm;
  }

  .book-meta-grid div {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
  }

  .book-meta-grid span {
    display: block;
    color: #6b7280;
    font-size: 10px;
  }

  .book-meta-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
  }

  .book-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .book-toc-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    padding: 7px 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
  }

  .book-toc-list small {
    display: block;
    margin-top: 2px;
    color: #6b7280;
    font-size: 11px;
  }

  .book-chapter-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 12mm;
    align-items: start;
  }

  .book-chapter-grid h2 {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.25;
  }

  .book-chapter-grid h3 {
    margin: 0 0 10mm;
    color: #2563eb;
    font-size: 15px;
  }

  .book-chapter-grid p,
  .book-chapter-grid li,
  .book-two-col li {
    color: #374151;
    font-size: 12px;
    line-height: 1.75;
  }

  .book-chapter-grid img {
    width: 100%;
    max-height: 170mm;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
  }

  .book-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12mm;
  }

  .book-two-col h2 {
    margin: 0 0 5mm;
    font-size: 18px;
  }

  .book-figure-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 12mm;
  }

  .book-figure-strip img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
  }
}

@media (max-width: 720px) {
  .diagnostic-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .image-card figcaption {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* 二次优化：结构化消息、可折叠诊断、外部图片结果展示 */
.message-content p {
  margin: 0 0 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content h3 {
  margin: 18px 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #e0f2fe;
  background: rgba(114, 229, 255, 0.075);
  border: 1px solid rgba(114, 229, 255, 0.16);
  font-size: 16px;
  line-height: 1.45;
}

.message-content h3:first-child {
  margin-top: 0;
}

.message-content ul {
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.message-content li {
  position: relative;
  padding: 9px 12px 9px 30px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.075);
  line-height: 1.7;
}

.message-content li::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(114, 229, 255, 0.10);
}

.code-card {
  margin: 14px 0 18px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(3, 7, 18, 0.54);
}

.code-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 13px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.055);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.message-content pre,
.code-card pre,
.print-content pre,
.print-message pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;
}

.code-card pre {
  margin: 0;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.24);
}

.asset-pill {
  display: inline-flex !important;
  align-items: center;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.10);
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.diagnostic-box {
  margin: 0 14px 14px;
}

.diagnostic-toggle {
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  text-align: left;
}

.diagnostic-toggle span {
  font-size: 12px;
  font-weight: 900;
}

.diagnostic-toggle small {
  color: var(--muted-2);
  font-size: 11px;
}

.diagnostic-content {
  margin-top: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.20);
  overflow: hidden;
}

.diagnostic-content[hidden] {
  display: none !important;
}

.image-card figcaption strong .asset-pill,
.image-card figcaption span.asset-pill {
  margin-top: 0;
}

.print-content h3 {
  margin: 14px 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eff6ff;
  color: #111827;
  font-size: 15px;
}

.print-content ul {
  margin: 0 0 12px 20px;
  padding: 0;
}

.print-content li {
  margin-bottom: 5px;
}

@media print {
  .code-card {
    border-color: #e5e7eb;
    background: #f9fafb;
  }

  .code-card-head {
    color: #374151;
    background: #f3f4f6;
    border-bottom-color: #e5e7eb;
  }

  .message-content li::before {
    display: none;
  }

  .asset-pill,
  .diagnostic-box,
  .message-actions {
    display: none !important;
  }
}

.diagnostic-box {
  border: 0;
  background: transparent;
  overflow: visible;
}

/* Minimal dark refresh: keeps the existing structure and behavior, only simplifies the visual skin. */
:root {
  --bg: #07080b;
  --bg-soft: #0c0f14;
  --panel: rgba(14, 18, 24, 0.94);
  --panel-strong: rgba(20, 25, 33, 0.98);
  --line: rgba(255, 255, 255, 0.10);
  --text: #f4f7fb;
  --muted: #9aa4b2;
  --muted-2: #687381;
  --brand: #38d7ff;
  --brand-2: #6ee7b7;
  --brand-3: #f4c95d;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  --radius-xl: 8px;
  --radius-lg: 8px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --sidebar: 300px;
}

body {
  background: #07080b;
}

.landing,
.shell {
  padding: 12px;
}

.hero-card,
.auth-card,
.panel-card,
.message-composer,
.chat-empty,
.paywall,
.admin-shell,
.sidebar,
.workspace,
.landing-nav,
.stat-card,
.plan-card,
.user-card,
.payment-box,
.qr-box,
.notice-card,
.diagnostic-box,
.diagnostic-content,
.progress-card,
.image-preview-dialog,
.table-wrap,
.test-output {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: none;
  backdrop-filter: none;
}

.landing-nav,
.hero-card,
.auth-card,
.panel-card,
.sidebar,
.workspace,
.message-composer,
.chat-empty,
.paywall,
.admin-shell {
  border-radius: 8px;
}

.brand-orb,
.logo-mark,
.avatar,
.message-avatar {
  border-radius: 8px;
  background: #111821;
  border: 1px solid var(--line);
  box-shadow: none;
  color: #dff7ff;
}

.message.assistant .message-avatar,
.message.user .message-avatar {
  background: #111821;
}

.hero-card::before,
.image-progress-card::before {
  display: none;
}

.gradient-text {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--text);
}

.hero-kicker,
.section-kicker,
.badge,
.image-message-details summary,
.cover-brief-box,
.settings-hint,
.progress-steps span,
.mode-switch,
.tool-pill,
.file-tool,
.image-settings-menu summary,
.image-option,
.auth-tabs,
.auth-tab,
.admin-tab {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
}

.hero-kicker,
.section-kicker {
  color: #b9f3ff;
  padding: 6px 10px;
}

.btn,
.icon-btn,
.send-icon-btn {
  border-radius: 6px;
  box-shadow: none;
}

.btn {
  min-height: 36px;
  border-color: var(--line);
  background: #121821;
}

.btn:hover,
.icon-btn:hover,
.side-link:hover,
.chat-item:hover,
.prompt-card:hover,
.tool-pill:hover,
.file-tool:hover,
.image-settings-menu summary:hover,
.image-option:hover {
  background: #18212b;
  border-color: rgba(56, 215, 255, 0.28);
  transform: none;
}

.btn.primary,
.send-icon-btn,
.auth-tab.active,
.mode-pill.active,
.image-option.active,
.admin-tab.active {
  color: #061015;
  border-color: rgba(56, 215, 255, 0.60);
  background: var(--brand);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: rgba(251, 113, 133, 0.10);
  border-color: rgba(251, 113, 133, 0.25);
}

.btn.success {
  background: rgba(52, 211, 153, 0.10);
  border-color: rgba(52, 211, 153, 0.25);
}

.input,
.textarea,
.select,
.tool-select,
.image-count-input {
  border-radius: 6px;
  background: #0b0f15;
  border-color: var(--line);
}

.input:focus,
.textarea:focus,
.select:focus,
.image-count-input:focus,
.composer-textarea:focus {
  border-color: rgba(56, 215, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 215, 255, 0.08);
}

.shell {
  gap: 12px;
  background: #07080b;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  top: 12px;
  height: calc(100vh - 24px);
}

.sidebar-head,
.topbar,
.composer-wrap,
.sidebar-foot {
  background: #0b0f15;
  border-color: var(--line);
}

.side-nav,
.chat-list {
  gap: 4px;
}

.side-link,
.chat-item {
  border-radius: 6px;
}

.side-link.active,
.chat-item.active {
  background: rgba(56, 215, 255, 0.10);
  border-color: rgba(56, 215, 255, 0.26);
}

.workspace {
  background: #090c11;
  height: calc(100vh - 24px);
  min-height: 0;
}

.main-panel,
.chat-view {
  min-height: 0;
}

.topbar {
  min-height: 64px;
  padding: 12px 18px;
}

.messages {
  padding: 18px 22px;
}

.welcome-card {
  max-width: 980px;
  padding: 8px 0 14px;
}

.prompt-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.prompt-card {
  border: 1px solid var(--line);
  background: #0d1219;
  border-radius: 8px;
  padding: 13px;
}

.prompt-card.featured {
  background: #101923;
  border-color: rgba(56, 215, 255, 0.25);
}

.message {
  max-width: 980px;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 36px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  font-size: 12px;
}

.message-body {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1118;
}

.message.user .message-body {
  background: #10151d;
  text-align: left;
}

.message-head {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.message.user .message-head {
  justify-content: flex-start;
  align-items: flex-start;
}

.message-content {
  color: #edf2f8;
  line-height: 1.72;
}

.message-content li,
.message-content h3,
.message-content pre,
.message-content blockquote,
.diagnostic-content pre,
.log-detail {
  border-radius: 6px;
  background: #090d13;
  border-color: var(--line);
}

.message-content li {
  padding: 10px 12px 10px 30px;
}

.message-content li::before {
  background: var(--brand);
  box-shadow: none;
}

.composer-wrap {
  padding: 12px 22px 16px;
}

.message-composer {
  max-width: 980px;
  padding: 10px;
  background: #0d1118;
}

.composer-textarea {
  min-height: 58px;
  padding: 8px 6px;
}

.send-icon-btn {
  background: var(--brand);
}

.tool-pill,
.file-tool,
.image-settings-menu summary,
.mode-pill,
.image-option {
  width: auto;
  min-width: 44px;
  min-height: 30px;
  padding-left: 10px;
  padding-right: 10px;
  white-space: nowrap;
}

.file-tool {
  min-width: 58px;
}

.upload-preview,
.pdf-upload-preview {
  border-radius: 6px;
  background: #111821;
}

.upload-preview img {
  border-radius: 5px;
}

.upload-remove-btn {
  box-shadow: none;
  background: #151c26;
}

.content-scroll {
  padding: 18px;
}

.page-grid {
  gap: 14px;
}

.panel-card {
  padding: 18px;
}

.card-head {
  margin-bottom: 14px;
}

.stats-grid,
.plans-grid {
  gap: 10px;
}

.stat-card,
.plan-card {
  padding: 15px;
  background: #0d1118;
}

.plan-card.selected {
  border-color: rgba(56, 215, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(56, 215, 255, 0.16);
}

.table-wrap {
  border-radius: 8px;
  background: #0d1118;
}

th {
  background: #101720;
}

td {
  background: transparent;
}

.message.assistant.image-focused,
.message.has-assets {
  max-width: 980px;
}

.message.assistant.image-focused .message-body {
  max-width: min(820px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1118;
}

.image-results {
  gap: 12px;
}

.image-card {
  width: min(320px, 100%);
  border-radius: 8px;
  background: #0b0f15;
}

.message.image-focused .image-card {
  background: #0b0f15;
}

.image-stage {
  border-radius: 8px;
  background: #070a0f;
}

.image-card figcaption,
.message.image-focused .image-card figcaption {
  border-radius: 0 0 8px 8px;
  background: transparent;
  padding: 9px 10px;
}

.image-actions-row {
  margin-top: 10px;
}

.image-preview-backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.image-preview-dialog {
  border-radius: 8px;
  background: #0d1118;
}

.progress-card {
  padding: 14px;
  border-radius: 8px;
  background: #0d1118;
}

.progressbar {
  height: 8px;
  border-radius: 999px;
}

.progressbar span,
.image-progress-card .progressbar span {
  background: var(--brand);
  animation: none;
}

.image-wait-preview span {
  border-radius: 6px;
  background: #121821;
}

.notice-card {
  border-radius: 8px;
  padding: 12px 14px;
}

.badge.ok {
  color: #b9f8d8;
  background: rgba(52, 211, 153, 0.09);
}

.badge.warn,
.badge.pending {
  color: #f8e6a1;
  background: rgba(251, 191, 36, 0.08);
}

.badge.bad,
.badge.rejected {
  color: #ffd0d8;
  background: rgba(251, 113, 133, 0.08);
}

.hero-card {
  min-height: 520px;
  padding: 42px;
}

.hero-card h1 {
  letter-spacing: 0;
  line-height: 1.04;
}

@media (max-width: 900px) {
  .landing,
  .shell {
    padding: 0;
  }

  .shell {
    gap: 0;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar,
  .workspace,
  .landing-nav,
  .hero-card,
  .auth-card,
  .panel-card,
  .message-composer {
    border-radius: 0;
  }

  .messages,
  .composer-wrap,
  .content-scroll {
    padding-left: 12px;
    padding-right: 12px;
  }

  .workspace {
    height: 100vh;
  }

  .prompt-grid,
  .stats-grid,
  .plans-grid {
    grid-template-columns: 1fr;
  }

  .message,
  .message.user {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .message.user .message-avatar,
  .message.user .message-body {
    grid-column: auto;
    grid-row: auto;
  }
}

/* Final layout clamps for the refreshed shell. */
html,
body,
#app {
  height: 100%;
  overflow: hidden;
}

body:has(.shell) {
  overflow: hidden;
}

body:has(.shell) .shell {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

body:has(.shell) .workspace {
  height: calc(100vh - 24px);
  min-height: 0;
}

body:has(.shell) .main-panel,
body:has(.shell) .chat-view {
  min-height: 0;
}

body:has(.shell) .messages {
  height: auto;
  min-height: 0;
}

.message-composer label.file-tool {
  width: auto;
  min-width: 62px;
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
}

.message-composer label.file-tool span {
  display: inline;
  width: auto;
  overflow: visible;
}

@media (max-width: 900px) {
  body:has(.shell) .workspace {
    height: 100vh;
  }
}

/* Detail polish for the compact dark interface. */
* {
  scrollbar-color: rgba(154, 164, 178, 0.42) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(154, 164, 178, 0.36);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(154, 164, 178, 0.54);
  background-clip: padding-box;
}

.btn.small,
.mode-pill,
.tool-pill,
.image-settings-summary,
.upload-remove-btn {
  border-radius: 6px;
}

.btn.primary {
  color: #041015;
  text-shadow: none;
}

.btn.primary:hover {
  filter: brightness(1.04);
}

.image-stage,
.message.image-focused .image-stage,
.image-stage.image-preview-trigger {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.image-stage:hover,
.image-stage.image-preview-trigger:hover {
  border-color: rgba(56, 215, 255, 0.26);
  background: #090d13;
}

.composer-textarea {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #090d13;
}

.composer-textarea:focus {
  border-color: rgba(56, 215, 255, 0.36);
  box-shadow: inset 0 0 0 1px rgba(56, 215, 255, 0.1);
  background: #080c12;
}

.send-icon-btn {
  border-radius: 6px;
}

/* Mobile interaction hotfix: keep the app usable under /znt on phone screens. */
@media (max-width: 900px) {
  html,
  body,
  #app {
    height: auto !important;
    min-height: 100dvh;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body:has(.shell),
  body:has(.shell) .shell {
    height: auto !important;
    min-height: 100dvh !important;
    overflow: visible !important;
  }

  .shell {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 !important;
  }

  .sidebar {
    position: relative !important;
    top: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border-radius: 0 !important;
    flex: 0 0 auto !important;
  }

  .sidebar-head {
    padding: 10px 12px 8px !important;
  }

  .sidebar-head .brand-subtitle,
  .sidebar-section-title {
    display: none !important;
  }

  .sidebar-foot {
    display: block !important;
    padding: 0 12px 10px !important;
    border-top: 0 !important;
  }

  .sidebar-foot .user-card {
    padding: 8px !important;
  }

  .sidebar-foot .user-card-row,
  .sidebar-foot .micro-copy {
    display: none !important;
  }

  .sidebar-actions {
    padding: 0 12px 8px !important;
  }

  .side-nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px !important;
    padding: 0 12px 8px !important;
  }

  .side-link {
    min-height: 44px !important;
    justify-content: center !important;
    padding: 8px !important;
  }

  .side-link .side-text small {
    display: none !important;
  }

  .side-icon {
    width: auto !important;
  }

  .chat-list {
    display: flex !important;
    gap: 6px !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 12px 10px !important;
    -webkit-overflow-scrolling: touch;
  }

  .chat-item {
    min-width: 180px !important;
    min-height: 44px !important;
  }

  body:has(.shell) .workspace,
  .workspace {
    height: auto !important;
    min-height: calc(100dvh - 178px) !important;
    overflow: visible !important;
    border-radius: 0 !important;
    flex: 1 1 auto !important;
  }

  .topbar {
    min-height: 52px !important;
    padding: 10px 12px !important;
    border-radius: 0 !important;
    flex-direction: row !important;
    align-items: center !important;
  }

  .topbar-title p {
    display: none !important;
  }

  .topbar-title h2 {
    font-size: 16px !important;
  }

  .topbar-actions {
    width: auto !important;
    flex: 0 0 auto !important;
  }

  .topbar-actions .btn {
    min-height: 36px !important;
    padding: 0 10px !important;
  }

  .main-panel,
  .chat-view {
    min-height: 0 !important;
    overflow: visible !important;
  }

  .chat-view {
    display: flex !important;
    flex-direction: column !important;
  }

  .messages {
    flex: 1 1 auto !important;
    min-height: 38dvh !important;
    max-height: none !important;
    overflow-y: visible !important;
    padding: 12px !important;
  }

  .message,
  .message.user {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
    max-width: 100% !important;
  }

  .message-avatar {
    display: none !important;
  }

  .message.user .message-body,
  .message.user .message-avatar {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .composer-wrap {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 30 !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
    background: rgba(7, 8, 11, 0.96) !important;
  }

  .message-composer {
    border-radius: 8px !important;
    padding: 8px !important;
  }

  .composer-textarea {
    min-height: 48px !important;
    max-height: 132px !important;
    font-size: 16px !important;
  }

  .composer-tools {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 8px !important;
  }

  .composer-tool-row {
    width: 100% !important;
    min-width: 0 !important;
    gap: 6px !important;
  }

  .composer-tool-row-right {
    width: auto !important;
    margin-left: 0 !important;
    justify-content: flex-end !important;
  }

  .composer-tools.image-mode-active {
    grid-template-columns: 1fr !important;
  }

  .composer-tools.image-mode-active .composer-mode-row,
  .composer-tools.image-mode-active .image-only-tools,
  .composer-tools.image-mode-active .composer-tool-row-right {
    grid-column: 1 / -1 !important;
  }

  .composer-tools.image-mode-active .image-only-tools {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .message-composer .upload-card {
    width: 100% !important;
    min-width: 0 !important;
  }

  .tool-pill,
  .file-tool,
  .message-composer label.file-tool,
  .upload-card,
  .image-settings-menu summary,
  .image-option,
  .btn,
  .icon-btn,
  .send-icon-btn {
    min-height: 44px !important;
    touch-action: manipulation;
  }

  .send-icon-btn {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
  }

  .image-settings-menu[open] .settings-popover {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-height: 58dvh !important;
    overflow-y: auto !important;
    z-index: 80 !important;
  }

  .image-results {
    grid-template-columns: 1fr !important;
  }

  .image-preview-dialog {
    width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
  }
}
