:root {
  --cream: #f5f0eb;
  --white: #ffffff;
  --ink: #1a1a1a;
  --peach: #e8c4a0;
  --peach-light: #f4d1c2;
  --taupe: #b8a998;
  --taupe-dark: #8a7e73;
  --line: #e6dcd0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--white);
  border: 0;
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity .15s;
}
button:hover { opacity: .85; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--white);
  padding: 48px 40px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.login-kicker {
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--taupe);
  margin-bottom: 8px;
}
.login-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 32px;
  margin: 0 0 8px;
  font-weight: 700;
}
.login-sub {
  margin: 0 0 32px;
  color: var(--taupe-dark);
  font-size: 13px;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--white);
  margin-bottom: 14px;
  border-radius: 0;
  font-family: inherit;
}
.login-form input:focus { outline: 1px solid var(--ink); }
.login-form button { width: 100%; padding: 13px; }
.error { color: #c0392b; font-size: 12px; margin-top: 16px; }

/* ---------- App layout ---------- */
.app-body { display: flex; flex-direction: column; height: 100vh; }
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-kicker {
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--taupe);
}
.brand-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 18px;
  font-weight: 700;
}
.header-actions { display: flex; gap: 8px; align-items: center; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  min-height: 0;
}

/* ---------- Chat pane ---------- */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--white);
  border-right: 1px solid var(--line);
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 13.5px;
  line-height: 1.5;
}
.msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--white);
}
.msg.assistant {
  align-self: flex-start;
  background: var(--cream);
  color: var(--ink);
}
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg .hint { font-size: 11px; color: var(--taupe-dark); }
.msg.error {
  background: #fbecea;
  color: #8a2620;
  align-self: stretch;
  font-size: 12px;
}

.compose {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.compose textarea {
  flex: 1;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  border-radius: 0;
}
.compose textarea:focus { outline: 1px solid var(--ink); }
.compose button { white-space: nowrap; }

.status {
  margin: 0;
  padding: 0 16px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--taupe);
  min-height: 16px;
}

/* ---------- Preview pane ---------- */
.preview {
  display: flex;
  flex-direction: column;
  background: var(--cream);
  padding: 18px;
  min-height: 0;
  gap: 12px;
}

/* Inbox preview strip — mimics how the email looks in a mail client list. */
.inbox-preview {
  display: flex;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 14px 18px;
  align-items: flex-start;
}
.inbox-preview.empty .inbox-subject,
.inbox-preview.empty .inbox-preheader {
  color: var(--taupe);
  font-style: italic;
}
.inbox-avatar {
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
}
.inbox-meta { flex: 1; min-width: 0; }
.inbox-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.inbox-from {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.inbox-time {
  font-size: 11px;
  color: var(--taupe-dark);
}
.inbox-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-preheader {
  font-size: 12px;
  color: var(--taupe-dark);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-shell {
  flex: 1;
  background: var(--white);
  border: 1px solid var(--line);
  overflow: hidden;
  min-height: 0;
}
#previewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.preview-hint {
  margin: 0 2px;
  font-size: 11px;
  color: var(--taupe-dark);
  letter-spacing: 0.5px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .preview { border-top: 1px solid var(--line); }
}
