:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --bg-strong: #f0ebe3;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --ink: #181818;
  --muted: #6c6c6c;
  --line: rgba(24, 24, 24, 0.08);
  --dark: #181818;
  --dark-2: #202020;
  --blue: #111111;
  --blue-soft: rgba(17, 17, 17, 0.06);
  --green: #17844e;
  --green-soft: rgba(23, 132, 78, 0.12);
  --amber: #cf8d17;
  --amber-soft: rgba(207, 141, 23, 0.14);
  --red: #b4432c;
  --red-soft: rgba(180, 67, 44, 0.12);
  --copper: #8d5524;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 13px;
  --shadow: 0 24px 64px rgba(35, 25, 18, 0.12);
  --sidebar-width: 296px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.86), transparent 34%),
    linear-gradient(180deg, #f8f6f2 0%, var(--bg-strong) 100%);
}

body {
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.sidebar {
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(180deg, var(--dark-2) 0%, var(--dark) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.02em;
  background:
    radial-gradient(circle at 32% 18%, rgba(255, 255, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #3a342d 0%, #111111 100%);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.05;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
}

.brand p {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  line-height: 1.4;
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
}

.auth-state {
  display: grid;
  gap: 10px;
}

.auth-state p,
.auth-state span {
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  line-height: 1.5;
}

.auth-state strong {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-actions button,
.auth-state button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.auth-actions button:hover,
.auth-state button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.primary-ghost,
.section-title button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-weight: 700;
}

.primary-ghost:hover,
.section-title button:hover,
.history-item:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-section {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 800;
}

.section-title button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.history-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  scrollbar-gutter: stable;
}

.history-item {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  text-align: left;
  transition: 0.16s ease;
}

.history-item strong {
  font-size: 13px;
  line-height: 1.45;
}

.history-item span {
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
}

.sidebar-footer span {
  display: inline-flex;
  padding: 9px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.main-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--copper);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar h2 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.thread {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 28px 132px;
  scrollbar-gutter: stable;
}

.thread::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
  width: 12px;
}

.thread::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(24, 24, 24, 0.22);
  background-clip: padding-box;
}

.welcome-card,
.job-card,
.composer {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.welcome-card {
  width: min(1060px, 100%);
  margin: 24px auto;
  padding: 24px;
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(201, 26, 9, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 238, 230, 0.9));
}

.welcome-card::after {
  content: "";
  position: absolute;
  inset: auto -70px -120px auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(17, 17, 17, 0.06), transparent 67%);
  pointer-events: none;
}

.welcome-copy {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 2px;
}

.welcome-copy .eyebrow {
  margin: 0;
}

.welcome-copy h3 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.welcome-copy p:not(.eyebrow) {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.example-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.example-grid button {
  min-height: 118px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at 88% 12%, rgba(141, 85, 36, 0.09), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 240, 229, 0.92));
  color: var(--ink);
  text-align: left;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 850;
  transition: 0.16s ease;
  box-shadow: 0 10px 24px rgba(35, 25, 18, 0.055);
}

.example-grid button:hover {
  transform: translateY(-2px);
  border-color: rgba(24, 24, 24, 0.14);
  box-shadow: 0 18px 38px rgba(35, 25, 18, 0.12);
}

.message {
  display: flex;
  width: min(1120px, 100%);
  margin: 0 auto 20px;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-bubble {
  min-width: 0;
  max-width: min(100%, 980px);
}

.message.user .message-bubble {
  width: min(760px, 88%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(35, 25, 18, 0.08);
}

.message.user p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.65;
}

.inline-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.inline-files span,
.attachment-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.assistant-mount {
  width: min(1060px, 100%);
}

.job-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.job-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 16px;
}

.job-card-header h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.job-card-header .muted {
  display: block;
  margin-top: 8px;
  font-size: 13px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 850;
}

.status-pill.good,
.gate-card.good {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn,
.gate-card.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.bad,
.gate-card.bad {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.pending,
.gate-card.pending {
  background: var(--blue-soft);
  color: var(--blue);
}

.step-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 0 24px 20px;
}

.step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
}

.step span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.12);
  color: inherit;
  font-size: 12px;
  font-weight: 900;
}

.step b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.step.done,
.step.active {
  border-color: rgba(15, 139, 95, 0.22);
  background: var(--green-soft);
  color: var(--green);
}

.step.active {
  border-color: rgba(24, 24, 24, 0.14);
  background: var(--blue-soft);
  color: var(--blue);
}

.step.failed {
  border-color: rgba(180, 35, 24, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.preview-grid,
.gate-grid,
.artifact-section,
.error-card,
.clarification-card {
  margin: 0 24px 22px;
}

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

.preview-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 21px;
  overflow: hidden;
  background: var(--surface-strong);
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background:
    linear-gradient(90deg, rgba(24, 24, 24, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(24, 24, 24, 0.035) 1px, transparent 1px),
    #faf8f4;
  background-size: 24px 24px;
}

.preview-card figcaption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.preview-card a,
.artifact-link {
  color: var(--blue);
  text-decoration: none;
}

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

.gate-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid currentColor;
}

.gate-card strong,
.gate-card span {
  display: block;
}

.gate-card span {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
}

.gate-card ul,
.error-card ul,
.clarification-card ol {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
}

.error-card,
.clarification-card,
.artifact-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--surface-strong);
}

.error-card {
  border-color: rgba(180, 35, 24, 0.2);
  background: var(--red-soft);
  color: var(--red);
}

.error-card h4,
.clarification-card h4,
.result-section-header h4 {
  margin: 0;
  font-size: 16px;
}

.clarification-card textarea {
  width: 100%;
  min-height: 110px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  resize: vertical;
  outline: none;
}

.clarification-card button {
  min-height: 42px;
  margin-top: 12px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 850;
}

.result-section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.result-section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.artifact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.artifact-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.artifact-link.primary {
  border-color: transparent;
  background: var(--dark);
  color: #fff;
}

.composer-shell {
  padding: 0 28px 24px;
}

.composer {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 13px 14px 12px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
}

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

.attachment-chip {
  border: 0;
}

.composer textarea {
  width: 100%;
  min-height: 82px;
  max-height: 220px;
  padding: 8px 4px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  resize: none;
  outline: none;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.composer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.toolbar-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 17, 17, 0.04);
  color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.toolbar-button:hover {
  transform: translateY(-1px);
  background: rgba(17, 17, 17, 0.07);
  border-color: rgba(24, 24, 24, 0.14);
}

.icon-toolbar-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
}

.icon-toolbar-button svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

#files {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.send-button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 15px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(17, 17, 17, 0.22);
}

.send-button:disabled,
.composer textarea:disabled,
.toolbar-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.toolbar-button:disabled:hover {
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.support-button {
  position: fixed;
  right: 28px;
  bottom: 206px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 240, 229, 0.95)),
    var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 44px rgba(35, 25, 18, 0.18);
  backdrop-filter: blur(16px);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.support-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 58px rgba(35, 25, 18, 0.22);
}

.support-dot {
  width: 34px;
  height: 34px;
  position: relative;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--dark);
}

.support-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45);
  animation: support-pulse 1.8s infinite;
}

.support-copy {
  display: grid;
  gap: 2px;
  text-align: left;
}

.support-copy strong {
  font-size: 14px;
  line-height: 1.1;
}

.support-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.support-collapse-handle {
  display: none;
}

@keyframes support-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(52, 211, 153, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

.auth-modal,
.support-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 24% 18%, rgba(202, 139, 58, 0.18), transparent 34%),
    radial-gradient(circle at 82% 72%, rgba(36, 129, 118, 0.14), transparent 30%),
    rgba(18, 18, 18, 0.42);
  backdrop-filter: blur(14px);
}

.auth-panel,
.support-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 240, 229, 0.96)),
    var(--surface);
  box-shadow: 0 32px 90px rgba(28, 21, 14, 0.28);
}

.auth-panel {
  width: min(460px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
}

.auth-panel-header h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.18;
}

.auth-panel-header p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.auth-panel label {
  display: grid;
  gap: 8px;
}

.auth-panel label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.auth-panel input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  outline: none;
}

.auth-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.auth-modal-actions button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(17, 17, 17, 0.04);
  color: var(--ink);
  font-weight: 900;
}

.auth-modal-actions button[type="submit"] {
  border-color: transparent;
  background: var(--dark);
  color: #fff;
}

.auth-modal-actions button:disabled {
  opacity: 0.55;
  cursor: default;
}

.auth-switch {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.auth-switch button {
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 950;
}

.auth-switch button:hover {
  text-decoration: underline;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-status[data-tone="error"] {
  color: var(--red);
  font-weight: 800;
}

.form-status[data-tone="success"] {
  color: var(--green);
  font-weight: 800;
}

.support-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.support-header h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.18;
}

.support-header p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.support-close {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 17, 17, 0.04);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.support-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.support-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.support-field select,
.support-field input,
.support-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  outline: none;
}

.support-field select,
.support-field input {
  min-height: 44px;
  padding: 0 13px;
}

.support-field textarea {
  min-height: 142px;
  padding: 13px;
  resize: vertical;
  line-height: 1.65;
}

.support-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
}

#support-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

#support-status[data-tone="success"] {
  color: var(--green);
  font-weight: 800;
}

#support-status[data-tone="error"] {
  color: var(--red);
  font-weight: 800;
}

#support-submit {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 15px;
  background: var(--dark);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(17, 17, 17, 0.22);
}

#support-submit:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 1120px) {
  :root {
    --sidebar-width: 258px;
  }

  .topbar {
    flex-direction: column;
  }

  .config-chips {
    justify-content: flex-start;
    max-width: none;
  }

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

@media (max-width: 860px) {
  :root {
    --mobile-topbar-height: 76px;
    --mobile-composer-height: 132px;
  }

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

  body {
    overflow: hidden;
    color: #f8f8f8;
  }

  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    background: #050505;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(82vw, 360px);
    height: 100dvh;
    padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 18px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0;
    background: #030303;
    box-shadow: 28px 0 80px rgba(0, 0, 0, 0.55);
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    will-change: transform;
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(5px);
  }

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

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    font-size: 13px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .auth-card {
    background: rgba(255, 255, 255, 0.08);
  }

  .primary-ghost {
    min-height: 54px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.15);
    font-size: 16px;
  }

  .section-title {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.72);
  }

  .history-item {
    min-height: 58px;
    padding: 11px 2px;
    border-color: transparent;
    border-radius: 0;
    background: transparent;
  }

  .history-item:hover {
    background: transparent;
  }

  .history-item strong {
    color: #fff;
    font-size: 16px;
  }

  .history-item span {
    font-size: 12px;
  }

  .history-list {
    max-height: none;
  }

  .main-panel {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-rows: var(--mobile-topbar-height) minmax(0, 1fr);
    background: #050505;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    min-height: var(--mobile-topbar-height);
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 8px;
    padding: calc(env(safe-area-inset-top) + 10px) 18px 10px;
    background:
      linear-gradient(180deg, rgba(5, 5, 5, 0.98), rgba(5, 5, 5, 0.84) 72%, rgba(5, 5, 5, 0));
  }

  .mobile-icon-button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #fff;
  }

  .mobile-icon-button span {
    width: 22px;
    height: 2px;
    display: block;
    margin: 2px 0;
    border-radius: 999px;
    background: currentColor;
  }

  .mobile-new-button {
    font-size: 30px;
    line-height: 1;
  }

  .mobile-title {
    display: grid;
    justify-items: center;
    gap: 2px;
    color: #fff;
  }

  .mobile-title strong {
    font-size: 19px;
    letter-spacing: 0.01em;
  }

  .mobile-title small {
    color: rgba(255, 255, 255, 0.48);
    font-size: 11px;
    font-weight: 800;
  }

  .preview-grid,
  .gate-grid,
  .step-rail {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: none;
  }

  .thread {
    padding: 18px 18px calc(var(--mobile-composer-height) + env(safe-area-inset-bottom) + 28px);
    background: #050505;
  }

  .composer-shell {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 14px);
    background:
      linear-gradient(180deg, rgba(5, 5, 5, 0), rgba(5, 5, 5, 0.94) 26%, #050505 100%);
  }

  .composer {
    padding: 10px 12px;
    border-color: rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    background: #1f1f1f;
    box-shadow: 0 20px 42px rgba(0, 0, 0, 0.35);
  }

  .composer textarea {
    min-height: 54px;
    padding: 4px 2px 8px;
    color: #fff;
    font-size: 15px;
  }

  .composer textarea::placeholder {
    color: rgba(255, 255, 255, 0.32);
  }

  .composer-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .composer-actions {
    flex: 0 0 auto;
  }

  .toolbar-button,
  .send-button {
    min-height: 42px;
    border-radius: 16px;
  }

  .icon-toolbar-button {
    width: 46px;
    min-width: 46px;
    height: 46px;
    border-color: rgba(255, 255, 255, 0.16);
    background: #2b2b2b;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }

  .icon-toolbar-button:hover {
    transform: none;
    background: #343434;
    border-color: rgba(255, 255, 255, 0.22);
  }

  .send-button {
    width: auto;
    min-width: 106px;
    padding: 0 16px;
    background: #fff;
    color: #111;
  }

  .attachment-chip {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .message {
    width: 100%;
  }

  .message.user .message-bubble {
    border-color: rgba(255, 255, 255, 0.1);
    background: #202020;
    color: #fff;
    box-shadow: none;
  }

  .message.assistant .message-bubble {
    width: 100%;
  }

  .welcome-card {
    width: 100%;
    margin: 12vh 0 0;
    padding: 0 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .welcome-card::after {
    display: none;
  }

  .welcome-copy {
    padding: 0 0 18px;
  }

  .welcome-copy .eyebrow {
    color: rgba(255, 255, 255, 0.64);
    font-size: 24px;
    letter-spacing: -0.02em;
    text-transform: none;
  }

  .example-grid {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 12px;
  }

  .example-grid button {
    width: auto;
    min-height: 48px;
    max-width: 94%;
    padding: 12px 16px;
    border-color: rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: #1d1d1d;
    color: #fff;
    box-shadow: none;
    font-size: 15px;
  }

  .job-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: #121212;
    color: #fff;
    box-shadow: none;
  }

  .job-card-header .muted,
  .result-section-header p,
  .muted {
    color: rgba(255, 255, 255, 0.55);
  }

  .support-button {
    top: var(--support-button-top, calc(100dvh - var(--mobile-composer-height) - 88px));
    right: 0;
    bottom: auto;
    z-index: 66;
    gap: 10px;
    min-height: 54px;
    padding: 8px 6px 8px 10px;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(31, 31, 31, 0.96);
    color: #fff;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
    touch-action: none;
    user-select: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }

  .support-button:hover {
    transform: none;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  }

  .support-button.is-dragging {
    transition: none;
  }

  .support-button.is-collapsed {
    transform: translateX(calc(100% - 44px));
  }

  .support-button.is-collapsed:hover {
    transform: translateX(calc(100% - 44px));
  }

  .support-dot {
    width: 32px;
    height: 32px;
    background: #fff;
  }

  .support-copy strong {
    color: #fff;
  }

  .support-copy small {
    color: rgba(255, 255, 255, 0.58);
  }

  .support-collapse-handle {
    width: 34px;
    min-height: 40px;
    display: grid;
    place-items: center;
    align-self: stretch;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }

  .support-collapse-handle::before {
    content: "›";
    color: rgba(255, 255, 255, 0.82);
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
  }

  .support-button.is-collapsed .support-collapse-handle::before {
    content: "‹";
  }

  .auth-modal {
    align-items: end;
    padding: 18px;
  }

  .auth-panel {
    width: 100%;
    max-width: none;
    border-color: rgba(255, 255, 255, 0.12);
    border-radius: 26px;
    background: #161616;
    color: #fff;
  }

  .auth-panel-header p,
  .auth-panel label span,
  .auth-switch,
  .form-status {
    color: rgba(255, 255, 255, 0.58);
  }

  .auth-panel input {
    border-color: rgba(255, 255, 255, 0.12);
    background: #202020;
    color: #fff;
  }

  .auth-modal-actions button {
    border-color: rgba(255, 255, 255, 0.16);
    background: #242424;
    color: #fff;
  }

  .auth-modal-actions button[type="submit"] {
    background: #fff;
    color: #111;
  }

  .auth-switch button {
    color: #fff;
  }
}

@media (max-width: 620px) {
  .topbar h2 {
    font-size: 23px;
  }

  .welcome-card,
  .job-card {
    border-radius: 20px;
  }

  .welcome-card {
    padding: 0 2px;
    margin: 10vh 0 0;
  }

  .welcome-copy {
    align-items: flex-start;
    flex-direction: column;
  }

  .example-grid button {
    min-height: 48px;
  }

  .job-card-header,
  .result-section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-toolbar {
    flex-direction: row;
    align-items: center;
  }

  .job-card-header,
  .step-rail,
  .preview-grid,
  .gate-grid,
  .artifact-section,
  .error-card,
  .clarification-card {
    margin-left: 16px;
    margin-right: 16px;
  }

  .job-card-header {
    margin: 0;
    padding-left: 16px;
    padding-right: 16px;
  }

  .message.user .message-bubble {
    width: 100%;
  }

  .send-button {
    width: auto;
    min-width: 94px;
    padding: 0 12px;
  }

  .support-copy small {
    display: none;
  }

  .support-panel {
    padding: 22px;
  }

  .support-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
