:root {
  color-scheme: dark;
  --bg: #101615;
  --panel: #151d1b;
  --panel-strong: #1b2522;
  --line: #2a3935;
  --line-strong: #426057;
  --text: #eff7f2;
  --muted: #9ab0a8;
  --primary: #6ee7b7;
  --primary-strong: #2dd4bf;
  --accent: #f7c873;
  --danger: #ff8b8b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(110, 231, 183, 0.12), transparent 32%),
    radial-gradient(circle at 100% 10%, rgba(247, 200, 115, 0.1), transparent 26%),
    linear-gradient(180deg, #0b1110 0%, var(--bg) 100%);
  color: var(--text);
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  width: min(1440px, calc(100vw - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
}

.sidebar,
.workspace {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(21, 29, 27, 0.9);
  box-shadow: var(--shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #07100e;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.conversation-item {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
}

.conversation-item.active {
  border-color: var(--primary);
  background: rgba(110, 231, 183, 0.09);
}

.conversation-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

.status-pill {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ready {
  color: var(--primary);
  border-color: rgba(110, 231, 183, 0.45);
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(255, 139, 139, 0.45);
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.08);
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1412;
  color: var(--text);
  outline: none;
}

select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 104px;
  padding: 14px;
  line-height: 1.65;
}

select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.13);
}

.chat-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 18px 22px;
}

.empty-chat {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.message {
  display: grid;
  gap: 10px;
  max-width: 920px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.message.user {
  margin-left: auto;
  background: rgba(110, 231, 183, 0.08);
}

.message.assistant {
  margin-right: auto;
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  line-height: 1.7;
  white-space: pre-wrap;
}

.message-image {
  width: min(100%, 720px);
  max-height: 640px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1110;
}

.ai-prompt-panel {
  border: 1px solid rgba(110, 231, 183, 0.24);
  border-radius: 12px;
  background: rgba(110, 231, 183, 0.05);
  overflow: hidden;
}

.ai-prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(110, 231, 183, 0.18);
}

.ai-prompt-head strong,
.ai-prompt-head span {
  display: block;
}

.ai-prompt-head strong {
  color: var(--primary);
  font-size: 13px;
}

.ai-prompt-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.copy-prompt-btn {
  flex: none;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 9px;
  background: rgba(110, 231, 183, 0.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.prompt-grid {
  display: grid;
}

.prompt-item + .prompt-item {
  border-top: 1px solid rgba(110, 231, 183, 0.12);
}

.prompt-item div {
  padding: 9px 10px 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.prompt-item pre {
  margin: 0;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #d8eee7;
  font-size: 12px;
  line-height: 1.6;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-list span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.13);
}

.progress-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(110, 231, 183, 0.28);
  border-radius: 14px;
  background: rgba(110, 231, 183, 0.06);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.progress-head strong,
.progress-head span {
  display: block;
}

.progress-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

#progressElapsed {
  flex: none;
  margin: 0;
  color: var(--primary);
  font-weight: 800;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.35s ease;
}

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

.progress-steps span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.progress-steps span.active {
  color: var(--primary);
  border-color: rgba(110, 231, 183, 0.55);
  background: rgba(110, 231, 183, 0.08);
}

.progress-steps span.done {
  color: var(--accent);
  border-color: rgba(247, 200, 115, 0.42);
}

.reference-row,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-box {
  flex: 1;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.upload-box span {
  margin: 0;
}

.reference-preview {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.reference-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
}

.reference-preview strong,
.reference-preview span {
  display: block;
  overflow-wrap: anywhere;
}

.reference-preview span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-btn {
  min-width: 128px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #06110f;
}

.secondary-btn,
.ghost-btn {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.ghost-btn:disabled,
.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: 180px;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 12px, 640px);
    margin: 6px auto;
  }

  .topbar,
  .reference-row,
  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .chat-panel,
  .composer,
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .primary-btn {
    width: 100%;
  }

  .progress-steps {
    grid-template-columns: 1fr;
  }

  .ai-prompt-head {
    align-items: stretch;
    flex-direction: column;
  }

  .copy-prompt-btn {
    width: 100%;
  }
}
