:root {
  --bg: #f4efe6;
  --panel: rgba(255, 250, 243, 0.88);
  --line: rgba(23, 35, 63, 0.12);
  --text: #17233f;
  --muted: #5f6d86;
  --navy: #163565;
  --blue: #254b86;
  --cyan: #5db7ff;
  --warm: #f08b49;
  --shadow: 0 22px 56px rgba(23, 35, 63, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.7), transparent 28%),
    linear-gradient(135deg, #efe5d5, #f7f1e9 44%, #e4e9f5 100%);
  color: var(--text);
  font-family: Manrope, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px;
  background: rgba(17, 33, 58, 0.95);
  color: #fbf7f1;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(145deg, #5eb7ff, #274d87);
  color: white;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.eyebrow,
.card-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

.brand h1,
.hero-copy h2,
.preview-toolbar h2,
.section-header h3 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  line-height: 1.02;
}

.brand h1 {
  font-size: 30px;
}

.card,
.hero-card,
.preview-panel,
.advanced-card {
  border-radius: 26px;
}

.card,
.status-card,
.email-card {
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
}

.status-card {
  background: linear-gradient(155deg, rgba(90, 182, 255, 0.2), rgba(255,255,255,0.06));
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.status-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  opacity: 0.72;
}

.muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0.78;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: rgba(9, 17, 31, 0.24);
  color: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(103, 186, 255, 0.9);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, #65b9ff, #2a548f);
  box-shadow: 0 14px 30px rgba(38, 84, 143, 0.28);
}

.button-secondary {
  color: white;
  background: linear-gradient(135deg, #f19b59, #ef6f4e 48%, #28528d);
  box-shadow: 0 16px 28px rgba(239, 111, 78, 0.22);
}

.button-ghost {
  color: var(--text);
  background: rgba(20, 35, 62, 0.06);
  border: 1px solid var(--line);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  gap: 24px;
  padding: 28px;
}

.hero-card,
.large-card,
.advanced-card,
.preview-panel,
.advanced-grid .card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  margin-bottom: 18px;
}

.hero-copy {
  max-width: 720px;
}

.hero-copy h2 {
  font-size: 34px;
  margin-bottom: 10px;
}

.hero-text {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.55;
}

.compose-card {
  padding: 22px;
}

.compose-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
}

.compose-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.compose-summary {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 210px;
}

.large-card {
  padding: 22px;
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h3 {
  font-size: 26px;
}

.template-pill {
  min-width: 240px;
}

.template-pill span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.template-pill select {
  background: white;
  color: var(--text);
  border-color: var(--line);
}

.raw-text {
  min-height: 290px;
  padding: 18px;
  border-radius: 20px;
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(23, 35, 63, 0.1);
  font-size: 16px;
  line-height: 1.6;
}

.ai-feedback {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(140deg, rgba(37, 75, 134, 0.08), rgba(240, 139, 73, 0.08));
}

.ai-feedback strong {
  display: block;
  margin-bottom: 6px;
}

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

.advanced-card {
  overflow: hidden;
}

.advanced-card summary {
  padding: 18px 22px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.advanced-card summary::-webkit-details-marker {
  display: none;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 18px 18px;
}

.advanced-grid .card {
  margin: 0;
  padding: 18px;
}

.advanced-grid input,
.advanced-grid textarea {
  background: white;
  color: var(--text);
  border-color: rgba(23, 35, 63, 0.1);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview-panel {
  padding: 22px;
}

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

.preview-toolbar h2 {
  font-size: 28px;
}

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

.preview-frame {
  position: sticky;
  top: 24px;
  min-height: 780px;
  display: block;
  padding: 18px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(37, 75, 134, 0.08), rgba(93, 183, 255, 0.16)),
    #f7f9fd;
  border: 1px solid rgba(37, 75, 134, 0.12);
}

#previewImage {
  width: min(100%, 510px);
  display: none;
  border-radius: 20px;
  box-shadow: 0 26px 48px rgba(23, 35, 63, 0.18);
}

.preview-placeholder {
  display: grid;
  place-items: center;
  width: min(100%, 510px);
  margin: 0 auto;
  aspect-ratio: 1080 / 1350;
  border: 2px dashed rgba(37, 75, 134, 0.18);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.preview-gallery {
  display: none;
  gap: 18px;
}

.preview-item {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 35, 63, 0.08);
}

.preview-item + .preview-item {
  margin-top: 18px;
}

.preview-item-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-item-file {
  margin: 4px 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.preview-item-image {
  width: min(100%, 460px);
  display: block;
  margin: 0 auto;
  border-radius: 18px;
  box-shadow: 0 26px 48px rgba(23, 35, 63, 0.18);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(17, 32, 57, 0.96);
  color: #fff;
  box-shadow: 0 20px 40px rgba(12, 19, 35, 0.24);
  animation: toast-in 220ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .shell,
  .main,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .preview-frame {
    min-height: auto;
  }
}

@media (max-width: 768px) {
  .sidebar,
  .main {
    padding: 18px;
  }

  .hero-card,
  .preview-toolbar,
  .section-header,
  .two-col {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    min-width: 0;
  }

  .button {
    width: 100%;
  }
}
