:root {
  --blush: #f2d7dc;
  --blush-soft: #faeef1;
  --blush-deep: #c78493;
  --cream: #fffaf7;
  --charcoal: #3e3737;
  --muted: #746a6a;
  --sage: #8a9a7b;
  --white: #ffffff;
  --border: #e6d7da;
  --shadow: 0 16px 40px rgba(62, 55, 55, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--blush-soft), var(--cream) 45%);
  color: var(--charcoal);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.eyebrow { color: var(--blush-deep); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.workspace {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px 28px 22px;
  display: grid;
  grid-template-columns: minmax(320px, .72fr) minmax(560px, 1.45fr);
  gap: 22px;
}
.panel { background: rgba(255,255,255,.92); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-heading { padding: 20px 22px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.status-pill { border-radius: 999px; padding: 6px 10px; background: var(--blush-soft); color: var(--muted); font-size: 12px; }

.chat-panel { display: flex; flex-direction: column; align-self: start; }
.chat-history { overflow-y: auto; padding: 20px 20px 14px; display: flex; flex-direction: column; gap: 12px; max-height: 340px; }
.message { max-width: 88%; padding: 12px 14px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; background: var(--blush-soft); border-bottom-left-radius: 4px; }
.message.user { align-self: flex-end; background: var(--charcoal); color: var(--white); border-bottom-right-radius: 4px; }
.chat-compose { border-top: 1px solid var(--border); padding: 14px 18px 18px; }
textarea, input { width: 100%; border: 1px solid var(--border); background: var(--white); color: var(--charcoal); border-radius: 10px; outline: none; }
textarea:focus, input:focus { border-color: var(--blush-deep); box-shadow: 0 0 0 3px rgba(199,132,147,.14); }
textarea { padding: 12px; resize: vertical; }
input { padding: 11px 12px; }
.compose-footer, .recipient-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.working-text { color: var(--charcoal); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; min-height: 18px; }
.working-text:not(:empty)::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--blush);
  border-top-color: var(--blush-deep);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; transition: transform .1s ease, opacity .1s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { background: var(--charcoal); color: white; }
.button.secondary { background: var(--blush); color: var(--charcoal); }
.button.small { padding: 8px 11px; font-size: 13px; }

.editor-panel { min-height: 710px; overflow: hidden; align-self: start; }
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 22px; }
.metadata-grid label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tabs { display: flex; gap: 3px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.tab { border: 0; background: transparent; color: var(--muted); padding: 11px 14px; border-bottom: 3px solid transparent; font-weight: 700; }
.tab.active { color: var(--charcoal); border-bottom-color: var(--blush-deep); }
.tab-pane { display: none; min-height: 500px; }
.tab-pane.active { display: block; }
#previewPane { background: #f5f2f1; padding: 18px; }
#emailPreview { width: 100%; min-height: 470px; border: 0; background: white; border-radius: 8px; }
.empty-state { min-height: 470px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--charcoal); margin-bottom: 8px; }
.flower-mark { font-size: 38px; color: var(--blush-deep); margin-bottom: 8px; }
.code-editor { min-height: 465px; border: 0; border-radius: 0; padding: 18px 22px; resize: vertical; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.5; }
.hint { margin: 0; padding: 10px 22px 16px; color: var(--muted); font-size: 12px; }

.send-panel { max-width: 1444px; margin: 0 auto 30px; display: grid; grid-template-columns: .6fr 1.4fr; gap: 28px; padding: 22px; }
.send-copy p { color: var(--muted); line-height: 1.5; margin: 10px 0 0; }
.recipient-summary { color: var(--muted); font-size: 13px; }
.send-actions { display: flex; gap: 10px; }
.oauth-note { margin-top: 10px; color: var(--muted); font-size: 12px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: var(--charcoal); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: all .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #7f3f4d; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .chat-panel, .editor-panel { min-height: auto; }
  .send-panel { margin-left: 28px; margin-right: 28px; grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar, .workspace { padding-left: 14px; padding-right: 14px; }
  .metadata-grid { grid-template-columns: 1fr; }
  .send-panel { margin-left: 14px; margin-right: 14px; }
  .compose-footer, .recipient-footer { align-items: stretch; flex-direction: column; }
  .send-actions { width: 100%; }
  .send-actions .button { flex: 1; }
}

.status-pill.working {
  background: var(--blush);
  color: var(--charcoal);
  font-weight: 700;
}

.gmail-connection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--blush-soft);
}
.connection-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.connection-status { margin-top: 3px; color: var(--charcoal); font-size: 13px; font-weight: 700; }
.connection-actions { display: flex; align-items: center; gap: 8px; }
a.button { display: inline-block; text-decoration: none; }

@media (max-width: 640px) {
  .gmail-connection { align-items: stretch; flex-direction: column; }
  .connection-actions { width: 100%; }
  .connection-actions .button { flex: 1; text-align: center; }
}
