:root {
  color-scheme: light;
  --page: #eef2f7;
  --surface: #fbfbfc;
  --surface-strong: #ffffff;
  --line: #e7e8ee;
  --line-strong: #dedfe6;
  --text: #282a31;
  --muted: #9a9ca8;
  --control: #ffffff;
  --control-shadow: 0 2px 8px rgba(24, 28, 38, 0.06);
  --primary: #cfd0d6;
  --primary-text: #ffffff;
  --composer-safe-space: 430px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(90deg, rgba(125, 165, 232, 0.26) 1px, transparent 1px) 0 0 / 32px 24px,
    linear-gradient(var(--page), var(--page));
}

button,
textarea,
select,
input,
.prompt-editor {
  font: inherit;
}

button,
a,
label,
select,
summary,
.task-card,
.prompt-editor {
  touch-action: manipulation;
}

textarea,
select,
input,
.prompt-editor {
  font-size: 16px;
}

.page-shell {
  width: min(656px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0 0;
}

.playground-shell {
  position: relative;
  min-height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(30, 42, 69, 0.08);
  overflow: hidden;
}

.canvas-stage {
  position: relative;
  min-height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 112px 20px var(--composer-safe-space);
  scroll-padding-bottom: var(--composer-safe-space);
}

.canvas-stage.has-tasks {
  padding-top: 96px;
}

.download-link {
  position: absolute;
  top: 26px;
  right: 254px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  box-shadow: var(--control-shadow);
}

.archive-toggle {
  position: absolute;
  top: 26px;
  right: 178px;
  z-index: 3;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  box-shadow: var(--control-shadow);
}

.archive-toggle.is-open,
.archive-toggle:hover {
  border-color: #d6e4ff;
  background: #f5f8ff;
  color: #2168df;
}

.archive-panel {
  position: absolute;
  top: 74px;
  right: 26px;
  z-index: 5;
  width: min(420px, calc(100% - 52px));
  max-height: min(560px, calc(100vh - 180px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 56px rgba(31, 36, 50, 0.16);
  overflow: hidden;
}

.archive-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-panel-head strong {
  color: #30333d;
  font-size: 15px;
}

.archive-panel-head button {
  min-height: 30px;
  border: 1px solid #e4e7ef;
  border-radius: 999px;
  background: #fff;
  color: #7b7f8d;
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.archive-list {
  min-height: 0;
  max-height: 100%;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

.archive-empty {
  margin: 8px 2px 2px;
  color: #9a9ca8;
  font-size: 13px;
}

.archive-task {
  box-shadow: none;
}

.access-pill {
  position: absolute;
  top: 24px;
  right: 26px;
  z-index: 3;
  display: inline-grid;
  grid-template-columns: auto 96px auto;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 5px 6px 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--control-shadow);
}

.access-pill span {
  color: #8b8d98;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.access-pill input {
  width: 96px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #f1f3f7;
  color: var(--text);
  outline: none;
  padding: 0 10px;
  font-size: 16px;
}

.access-pill button {
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #2d74e8;
  color: #fff;
  cursor: pointer;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 750;
}

.access-pill.is-unlocked {
  grid-template-columns: auto auto;
}

.access-pill.is-unlocked input {
  display: none;
}

.access-pill.is-unlocked button {
  background: #e9f4ed;
  color: #2c8b4d;
  cursor: default;
}

.result-empty {
  min-height: 330px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 26px;
  color: #aaa6b3;
  text-align: center;
}

.result-empty p {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
}

.canvas-stage.has-tasks .result-empty {
  display: none;
}

.empty-icon {
  width: 68px;
  height: 68px;
  border: 4px solid #e3e4e9;
  border-radius: 11px;
  position: relative;
}

.empty-icon::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  height: 24px;
  border: 4px solid #e3e4e9;
  border-top: 0;
  border-right: 0;
  transform: skewY(-36deg);
  border-radius: 4px;
}

.empty-icon span {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #e3e4e9;
}

.result-card {
  width: 100%;
  min-height: 420px;
  display: grid;
  place-items: center;
}

.result-card img {
  max-width: 100%;
  max-height: calc(100vh - 360px);
  border-radius: 14px;
  box-shadow: 0 18px 55px rgba(25, 31, 45, 0.16);
}

.task-feed {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  margin: 0 auto;
  width: min(100%, 560px);
}

.task-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(224, 227, 237, 0.94);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 42px rgba(37, 48, 73, 0.11);
  backdrop-filter: blur(18px);
  animation: task-card-in 0.22s ease-out both;
}

.history-task {
  border-color: rgba(214, 219, 230, 0.86);
}

.history-task.is-completed {
  cursor: pointer;
}

.task-card.is-selected {
  border-color: rgba(73, 134, 244, 0.72);
  box-shadow: 0 22px 50px rgba(48, 106, 225, 0.16);
}

@keyframes task-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.task-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
}

.task-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: #edf4ff;
  color: #2268df;
  font-size: 13px;
  font-weight: 800;
}

.task-card.is-completed .task-state {
  background: #eaf6ef;
  color: #27824b;
}

.task-card.is-failed .task-state {
  background: #fff0ef;
  color: #d84839;
}

.task-card-head small {
  justify-self: end;
  color: #9a9ca8;
  font-size: 12px;
  font-weight: 750;
}

.task-time {
  margin-top: -4px;
  color: #a2a5b1;
  font-size: 12px;
  font-weight: 700;
}

.task-download,
.task-archive,
.task-restore {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #edf4ff;
  color: #2168df;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.task-download:hover,
.task-archive:hover,
.task-restore:hover {
  background: #dfeaff;
}

.task-archive {
  background: #f3f4f8;
  color: #737786;
}

.task-restore {
  background: #eaf6ef;
  color: #27824b;
}

.task-toggle {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #e4e7ef;
  border-radius: 999px;
  background: #fff;
  color: #7b7f8d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.task-toggle:hover {
  color: #2168df;
  border-color: #d6e4ff;
  background: #f5f8ff;
}

.task-prompt {
  margin: 0;
  color: #31333c;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
}

.task-refs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.task-refs img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(25, 31, 45, 0.08);
}

.task-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceef4;
}

.task-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5592ff, #246ee8);
  transition: width 0.32s ease;
}

.task-message {
  margin: 0;
  color: #9295a3;
  font-size: 13px;
}

.task-preview {
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background: #eef1f6;
}

.task-preview img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.task-card.is-collapsed .task-refs,
.task-card.is-collapsed .task-progress,
.task-card.is-collapsed .task-message,
.task-card.is-collapsed .task-preview {
  display: none;
}

.task-card.is-collapsed .task-prompt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.composer-panel {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 22px;
  display: grid;
  gap: 14px;
  padding: 34px 20px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 42px rgba(31, 36, 50, 0.1);
}

.composer-handle {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 60px;
  height: 5px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #c9cbd2;
  cursor: pointer;
  transform: translateX(-50%);
}

.composer-handle::after {
  content: "";
  position: absolute;
  inset: -14px -18px;
}

.advanced-panel {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.24s ease, opacity 0.18s ease, margin 0.24s ease;
}

.advanced-panel > .composer-options {
  overflow: hidden;
}

.composer-panel.is-collapsed {
  gap: 12px;
}

.composer-panel.is-collapsed .advanced-panel {
  grid-template-rows: 0fr;
  margin-top: -10px;
  opacity: 0;
  pointer-events: none;
}

.composer-panel.is-collapsed .reference-row {
  min-height: 0;
}

.composer-panel.is-collapsed .reference-list,
.composer-panel.is-collapsed .field-hint {
  display: none;
}

.prompt-wrap {
  position: relative;
}

.prompt-box textarea {
  display: none;
}

.prompt-editor {
  width: 100%;
  min-height: 70px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-strong);
  color: var(--text);
  line-height: 1.55;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: #c6c7cf;
  font-weight: 600;
  pointer-events: none;
}

.mention-token {
  display: inline-block;
  padding: 1px 7px 2px;
  border-radius: 999px;
  background: #eaf2ff;
  color: #1f65d9;
  font-weight: 750;
}

.mention-menu {
  position: absolute;
  left: 18px;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: min(330px, calc(100vw - 72px));
  min-width: 230px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 34px rgba(31, 36, 50, 0.14);
}

.mention-menu button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-weight: 650;
}

.mention-menu button:hover {
  background: #f1f3f7;
}

.mention-reference-list {
  display: grid;
  gap: 6px;
  max-height: 218px;
  overflow: auto;
}

.mention-empty {
  padding: 12px 10px;
  color: var(--muted);
  font-size: 13px;
}

.mention-reference-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  height: auto;
  padding: 7px;
}

.mention-reference-item img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(20, 26, 38, 0.08);
}

.mention-reference-item span {
  min-width: 0;
  overflow: hidden;
  color: #4b4d57;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-reference-item strong {
  color: #9a9ca8;
  font-size: 12px;
}

.mention-reference-item.is-selected {
  background: #edf5ff;
}

.mention-reference-item.is-selected strong {
  color: #1f65d9;
}

.mention-upload {
  margin-top: 6px;
  border-top: 1px solid #eef0f4 !important;
  color: #306fdc !important;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field span,
.field summary,
.field-hint {
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

select,
.optional-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--control);
  color: var(--text);
  outline: none;
  box-shadow: var(--control-shadow);
}

select {
  height: 44px;
  padding: 0 16px;
  font-size: 16px;
}

.optional-field {
  grid-column: 1 / -1;
}

.optional-field summary {
  width: max-content;
  cursor: pointer;
  list-style: none;
}

.optional-field summary::-webkit-details-marker {
  display: none;
}

.optional-field summary::after {
  content: "+";
  margin-left: 8px;
}

.optional-field[open] summary::after {
  content: "-";
}

.optional-field textarea {
  min-height: 70px;
  margin-top: 8px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}

.reference-row {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 10px;
}

.upload-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #e8e8ed;
  color: #6f7079;
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
}

.upload-button input {
  display: none;
}

.reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.reference-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 5px 8px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: #777986;
  font-size: 12px;
}

.reference-chip img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
}

.reference-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-chip button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #a7a8b1;
  cursor: pointer;
}

.actions {
  display: grid;
  grid-template-columns: minmax(180px, 330px);
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.actions::before {
  content: none;
}

.primary-button {
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 15px;
  background: var(--primary);
  color: var(--primary-text);
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
}

.primary-button:not(:disabled) {
  background: linear-gradient(180deg, #4f8fff, #1f65d9);
  box-shadow: 0 14px 28px rgba(31, 101, 217, 0.22);
}

.primary-button:disabled {
  cursor: wait;
}

.inline-status {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
}

.inline-status.is-empty {
  display: none;
}

.progress-shell {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #ececf0;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #2b73f0;
  transition: width 0.32s ease;
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.44;
}

@media (max-width: 720px) {
  .page-shell {
    width: 100%;
    padding: 0;
  }

  .playground-shell {
    min-height: 100vh;
    max-height: 100vh;
    border-left: 0;
    border-right: 0;
  }

  .canvas-stage {
    min-height: 100vh;
    max-height: 100vh;
    padding-bottom: var(--composer-safe-space);
  }

  .archive-panel {
    top: 72px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 116px);
  }

  .composer-panel {
    left: 12px;
    right: 12px;
    bottom: 14px;
    padding: 30px 16px 16px;
  }

  .composer-options {
    gap: 10px;
  }

  .field span,
  .field summary,
  .field-hint {
    font-size: 14px;
  }

  .primary-button {
    font-size: 18px;
  }
}

