:root {
  --bg: #f3f6f7;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66747f;
  --line: #d7e0e5;
  --accent: #176b67;
  --accent-dark: #0e4d4b;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.app {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(420px, 1fr);
  gap: 20px;
  max-width: 1360px;
  margin: 0 auto;
}

.panel,
.preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: calc(100vh - 56px);
}

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

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.badge.ready {
  color: var(--accent-dark);
  border-color: #9bc7c3;
  background: #eef8f7;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(23, 107, 103, 0.18);
  border-color: var(--accent);
}

button,
.ghostButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button {
  color: #fff;
  background: var(--accent);
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.chatBox {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  overflow: auto;
}

.message {
  display: grid;
  gap: 5px;
  max-width: 92%;
  padding: 11px 12px;
  border-radius: 8px;
  line-height: 1.5;
}

.message.assistant {
  justify-self: start;
  background: #ffffff;
  border: 1px solid var(--line);
}

.message.user {
  justify-self: end;
  color: #ffffff;
  background: var(--accent);
}

.examples {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.uploadCard {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
  padding: 12px;
  min-height: 78px;
  border: 1px dashed #9aa8b2;
  border-radius: 8px;
  background: #ffffff;
}

.uploadCard input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.uploadCard.hasImage {
  border-style: solid;
  border-color: #9bc7c3;
  background: #f5fbfa;
}

.uploadCopy {
  display: grid;
  gap: 4px;
}

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

#referencePreview {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fafb;
}

.uploadCard:not(.hasImage)::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: var(--accent);
  font-size: 34px;
  border-radius: 6px;
  background: #eef8f7;
}

#clearImageButton {
  position: relative;
  z-index: 1;
  min-height: 34px;
  padding: 0 12px;
  color: #334155;
  background: #ffffff;
  border-color: var(--line);
}

#clearImageButton:hover {
  background: #f1f5f9;
}

.batchBar {
  display: grid;
  grid-template-columns: 108px 108px 1fr;
  gap: 10px;
  align-items: center;
  margin: 12px 0 0;
}

.batchUploadButton,
#batchDownloadButton {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #334155;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.batchUploadButton {
  position: relative;
  overflow: hidden;
}

.batchUploadButton input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#batchDownloadButton {
  margin: 0;
}

#batchDownloadButton:not(:disabled):hover,
.batchUploadButton:hover {
  background: #eef8f7;
  color: var(--accent-dark);
}

#batchDownloadButton:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#batchStatus {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batchList {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 166px;
  overflow: auto;
}

.batchItem {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.batchItem img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.batchItem span {
  display: block;
  padding: 5px 6px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batchItem.done {
  border-color: #70b7a9;
}

.batchItem.error {
  border-color: #ef9a9a;
}

.exampleButton {
  width: 100%;
  min-height: auto;
  justify-content: flex-start;
  padding: 10px 12px;
  color: #334155;
  background: #ffffff;
  border-color: var(--line);
  font-weight: 400;
  text-align: left;
}

.exampleButton:hover {
  color: var(--accent-dark);
  background: #eef8f7;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  resize: none;
  min-height: 96px;
}

.composer button {
  min-height: 96px;
}

.preview {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

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

.ghostButton {
  color: var(--accent-dark);
  background: #eef8f7;
  border-color: #b7d8d5;
}

.ghostButton[hidden] {
  display: none;
}

.imageStage {
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(45deg, #eef2f4 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f4 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f4 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.imageStage img {
  max-width: min(100%, 780px);
  max-height: calc(100vh - 190px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.emptyState {
  width: min(100%, 420px);
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #9aa8b2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.promptBox {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.promptBox summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: #25313a;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

@media (max-width: 980px) {
  .app {
    padding: 14px;
  }

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

  .preview {
    min-height: 560px;
  }

  .panel {
    min-height: auto;
  }

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

  .composer button {
    min-height: 46px;
  }

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

  #batchStatus {
    grid-column: 1 / -1;
  }
}

/* 网站备案信息 */
.filingFooter {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 16px 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.filingFooter a {
  color: var(--accent-dark);
  text-decoration: none;
}

.filingFooter a:hover,
.filingFooter a:focus-visible {
  text-decoration: underline;
}
