@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --blue: rgb(22, 49, 114);
  --blue-soft: rgba(22, 49, 114, 0.1);
  --paper: rgb(250, 252, 253);
  --surface: rgb(255, 255, 255);
  --line: rgb(224, 228, 234);
  --ink: rgb(20, 24, 31);
  --mute: rgb(120, 130, 142);
  --font-body: "Montserrat", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 100px;
  padding: 4px 10px;
  white-space: nowrap;
}

.stat-badge.flood {
  color: var(--surface);
  background: var(--blue);
  font-weight: 600;
}

.stat-badge.all-read {
  color: var(--mute);
  background: transparent;
  border: 1px solid var(--line);
}

.mode-toggle {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--mute);
  background: transparent;
  border: none;
  border-radius: 100px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.active {
  background: var(--blue);
  color: white;
}

.reset-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 160ms ease;
}

.reset-btn:hover {
  background: var(--blue-soft);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

.list-pane {
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

.list-pane-header {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  padding: 16px 16px 8px;
}

.email-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.email-item {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms ease;
}

.email-item:hover {
  background: rgba(22, 49, 114, 0.04);
}

.email-item.selected {
  background: var(--blue-soft);
}

.avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.email-item-body {
  min-width: 0;
  flex: 1;
}

.email-item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.from-name {
  font-size: 13px;
  font-weight: 600;
}

.email-item.unread .from-name,
.email-item.unread .subject {
  font-weight: 700;
}

.email-item {
  background: var(--paper);
}

.email-item:not(.unread) .from-name,
.email-item:not(.unread) .subject {
  color: var(--mute);
}

.email-item.unread {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--blue);
}

.email-item.unread .subject {
  color: var(--blue);
}

.email-item.selected,
.email-item.unread.selected {
  background: var(--blue-soft);
}

.unread-dot {
  flex-shrink: 0;
  align-self: center;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--blue);
}

.email-item:not(.unread) .unread-dot {
  background: transparent;
}

.received {
  font-size: 11px;
  color: var(--mute);
  white-space: nowrap;
}

.subject {
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview {
  font-size: 12px;
  color: var(--mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item.raw .avatar {
  background: var(--mute);
}

.reading-pane {
  overflow-y: auto;
  padding: 32px 40px;
}

.empty-state {
  color: var(--mute);
  font-size: 14px;
  margin-top: 60px;
  text-align: center;
}

.reading-header h1 {
  font-family: var(--font-body);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px;
  max-width: 640px;
}

.reading-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.from-line {
  font-size: 13px;
}

.reading-body {
  font-size: 14px;
  line-height: 1.7;
  max-width: 680px;
}

.reading-body h3 {
  font-size: 14px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  margin: 28px 0 8px;
}

.reading-body h4 {
  font-size: 15px;
  margin: 4px 0 8px;
}

.reading-body a {
  color: var(--blue);
}

.raw-snippet {
  font-size: 13.5px;
  color: var(--mute);
  font-style: italic;
  max-width: 560px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.flood-banner {
  max-width: 560px;
  margin: 64px auto 0;
  text-align: center;
}

.flood-banner-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 16px;
}

.flood-banner-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--mute);
  margin: 0 0 14px;
  text-align: left;
}

.flood-banner-body:last-of-type {
  margin-bottom: 24px;
}

.flood-banner-body strong {
  color: var(--ink);
}

.flood-banner .empty-state {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  text-align: center;
}

.flood-banner-cta {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  color: white;
  background: var(--blue);
  border: none;
  border-radius: 100px;
  padding: 10px 22px;
  cursor: pointer;
  transition: opacity 160ms ease;
}

.flood-banner-cta:hover {
  opacity: 0.85;
}

.attachments {
  max-width: 680px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.attachments-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  margin-bottom: 10px;
}

.attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.attachment-chip:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.attachment-icon {
  font-size: 14px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 31, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: 640px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 80px);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 24px 48px -16px rgba(22, 49, 114, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--mute);
}

.modal-close {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--mute);
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  overflow-y: auto;
  padding: 24px 20px;
}

.doc-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 4px;
}

.doc-subheading {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  margin-bottom: 20px;
}

.doc-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.doc-label {
  font-weight: 600;
  color: var(--mute);
}

.doc-value {
  color: var(--ink);
  line-height: 1.6;
}
