:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --surface: #ffffff;
  --paper: #f6f3ea;
  --mist: #edf5f1;
  --blue: #174ea6;
  --blue-soft: #dbeafe;
  --green: #246b57;
  --amber: #c98524;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--mist), var(--paper) 48%, #f8fbff);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid rgba(23, 32, 42, 0.08);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.toolbar,
.preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment,
.icon-button {
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.segment.is-active {
  background: var(--blue);
  color: #ffffff;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(23, 32, 42, 0.06);
}

.icon-button:hover,
.segment:hover {
  border-color: #aeb8c4;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 34px);
  padding: clamp(18px, 4vw, 42px);
}

.sidebar,
.preview-panel {
  min-width: 0;
}

.campaign-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.campaign-summary span,
.preview-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.campaign-summary strong {
  font-size: 18px;
  line-height: 1.25;
}

.email-list {
  display: grid;
  gap: 8px;
}

.email-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(23, 32, 42, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.email-item:hover,
.email-item.is-active {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(23, 32, 42, 0.09);
}

.email-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 14px;
  font-weight: 900;
}

.email-item.is-active .email-number {
  background: var(--amber);
  color: #ffffff;
}

.email-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.email-copy strong,
.email-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-copy strong {
  font-size: 14px;
}

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

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.preview-header {
  justify-content: space-between;
}

.preview-title {
  min-width: 0;
  text-align: center;
}

.preview-title h2 {
  margin-top: 4px;
  overflow: hidden;
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage {
  display: grid;
  justify-items: center;
  min-height: 680px;
  padding: clamp(18px, 3vw, 36px);
  overflow: auto;
  border: 1px solid rgba(23, 32, 42, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 42, 0.04) 1px, transparent 1px),
    #f9fafb;
  background-size: 28px 28px;
  box-shadow: var(--shadow);
}

iframe {
  width: 500px;
  height: 780px;
  max-width: 100%;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(23, 32, 42, 0.16);
}

.stage.mobile iframe {
  width: 390px;
  height: 760px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 840px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .segmented {
    flex: 1;
  }

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

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

  .stage {
    min-height: 620px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .workspace {
    padding: 16px;
  }

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

  .segmented {
    width: 100%;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .toolbar .icon-button {
    width: 100%;
  }

  .email-list {
    grid-template-columns: 1fr;
  }

  .preview-header {
    gap: 8px;
  }

  .stage {
    padding: 12px;
  }
}
