:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #667085;
  --line: #d9e2ec;
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #1267d8;
  --accent-strong: #0b4fab;
  --success: #067647;
  --error: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(45, 212, 191, 0.2), transparent 30%),
    radial-gradient(circle at 88% 8%, rgba(244, 114, 182, 0.18), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #eef6ff 48%, #fff7ed 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
}

.composer-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(30, 41, 59, 0.14);
  backdrop-filter: blur(18px);
}

.composer-panel {
  border-radius: 24px;
  padding: 24px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.sender-chip {
  display: grid;
  gap: 4px;
  max-width: 270px;
  padding: 12px 14px;
  border: 1px solid rgba(18, 103, 216, 0.22);
  border-radius: 16px;
  background: #eef6ff;
}

.sender-chip span {
  color: var(--muted);
  font-size: 12px;
}

.sender-chip strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

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

.field,
.template-strip {
  min-width: 0;
}

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

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

.field span,
.preview-toolbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
  padding: 13px 14px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: rgba(18, 103, 216, 0.64);
  box-shadow: 0 0 0 4px rgba(18, 103, 216, 0.12);
}

.template-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  display: grid;
  gap: 9px;
  min-height: 88px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.template-card.active {
  border-color: rgba(18, 103, 216, 0.72);
  box-shadow: 0 0 0 4px rgba(18, 103, 216, 0.12);
}

.template-card strong {
  font-size: 14px;
}

.swatch {
  width: 100%;
  height: 28px;
  border-radius: 10px;
}

.swatch.aurora {
  background: linear-gradient(135deg, #2dd4bf, #7c3aed, #f472b6);
}

.swatch.sunset {
  background: linear-gradient(135deg, #fb7185, #f97316, #facc15);
}

.swatch.ocean {
  background: linear-gradient(135deg, #0ea5e9, #14b8a6, #84cc16);
}

.swatch.neon {
  background: linear-gradient(135deg, #111827, #4338ca, #db2777);
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
}

.send-button,
.preview-toolbar button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 13px 18px;
}

.send-button:hover,
.preview-toolbar button:hover {
  background: var(--accent-strong);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--error);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.preview-toolbar button {
  padding: 10px 14px;
}

iframe {
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 0;
  background: white;
}

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

  .preview-panel {
    min-height: 720px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .composer-panel {
    padding: 18px;
  }

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

  .compose-form,
  .template-strip {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 29px;
  }
}
