:root {
  color-scheme: light;
  --bg: #eef2f6;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --dark: #101828;
  --dark-2: #182230;
  --blue: #1570ef;
  --green: #12b76a;
  --soft-blue: #eff6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 156px;
  padding: 26px 28px;
  color: #fff;
  background: linear-gradient(135deg, var(--dark), #1d2939);
  border-radius: 16px;
}

.hero > div {
  min-width: 0;
  max-width: 100%;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8dd8c0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

h3 {
  font-size: 14px;
  line-height: 1.4;
}

.hero-copy {
  max-width: 620px;
  margin: 12px 0 0;
  color: #d0d5dd;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: #d1fadf;
  background: rgba(18, 183, 106, 0.12);
  border: 1px solid rgba(18, 183, 106, 0.35);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  margin-top: 18px;
}

.composer,
.result-panel {
  min-width: 0;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
}

.composer {
  padding: 18px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  background: #f2f4f7;
  border: 1px solid #e4e7ec;
  border-radius: 12px;
}

.mode-tab {
  min-height: 40px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
}

.mode-tab.is-active {
  color: #fff;
  background: var(--dark-2);
}

.mail-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.mail-form.is-hidden {
  display: none;
}

.form-heading {
  margin-bottom: 6px;
}

.form-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

label {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  border: 1px solid #cfd6e2;
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.6;
  outline: none;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 112, 239, 0.12);
}

.primary-action,
.ghost-action {
  min-height: 40px;
  border-radius: 10px;
  font-weight: 700;
}

.primary-action {
  align-self: flex-start;
  min-width: 128px;
  margin-top: 4px;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ghost-action {
  padding: 0 13px;
  color: #175cd3;
  background: var(--soft-blue);
  border: 1px solid #b2ddff;
}

.ghost-action:disabled {
  cursor: not-allowed;
  color: #98a2b3;
  background: #f2f4f7;
  border-color: #e4e7ec;
}

.result-panel {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  overflow: hidden;
}

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

.version-label {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result-text {
  flex: 1 1 auto;
  min-height: 320px;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  overflow: auto;
  color: #1d2939;
  background: #fbfcfe;
  line-height: 1.7;
}

.result-text.is-error {
  color: #b42318;
  background: #fff6f5;
}

.version-history,
.refine-form {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.version-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #344054;
}

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

.version-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

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

.version-item {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  text-align: left;
  color: #344054;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
}

.version-item.is-active {
  color: #101828;
  background: var(--soft-blue);
  border-color: #84caff;
}

.version-item strong,
.version-item span {
  display: block;
}

.version-item strong {
  font-size: 13px;
}

.version-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refine-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.refine-form textarea {
  min-height: 92px;
}

.refine-form .primary-action {
  align-self: stretch;
}

@media (max-width: 860px) {
  .app-shell {
    width: auto;
    max-width: none;
    margin: 0 10px;
    padding-top: 10px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
    padding: 22px;
  }

  h1 {
    font-size: 26px;
  }

  .mode-tabs {
    gap: 6px;
  }

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

  .result-panel {
    min-height: 360px;
  }

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

  .result-head .ghost-action {
    width: 100%;
  }

  .result-text {
    min-height: 260px;
  }
}
