:root {
  color-scheme: normal;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-strong: #dce6f2;
  --text: #1f3047;
  --muted: #6f7d97;
  --accent: #2c6ef5;
  --accent-soft: #e6efff;
  --border: rgba(47, 81, 183, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f3f4;
  color: var(--text);
}

.page-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  cursor: default;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.12);
  margin-bottom: 22px;
}

.hero-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}

.hero-action-button {
  width: 120px;
  min-width: 120px;
  padding: 10px 18px;
  flex: 0 0 auto;
}

.banner-title {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-icon {
  border-radius: 12px;
  border: none;
  width: 40px;
  height: 40px;
  background: var(--accent-soft);
  padding: 8px;
}

.banner-title {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  font-weight: 300;
}

.hero-button-row,
.button-row {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.refresh-button,
.secondary-button {
  min-width: 140px;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.refresh-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(44, 110, 245, 0.22);
}

.refresh-button:hover {
  background: #2260d6;
}

.secondary-button {
  color: var(--text);
  background: #f1f3f4;
  border: 1px solid rgba(60, 64, 67, 0.12);
}

.secondary-button:hover {
  background: #e8eaed;
}

.auth-card {
  margin: 24px 0;
  padding: 20px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(60, 64, 67, 0.12);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.12);
}

.hidden {
  display: none;
}

.auth-label {
  margin: 0 0 12px;
  color: #29426a;
  font-weight: 600;
}

.auth-input-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.auth-input {
  flex: 1 1 320px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid rgba(47, 81, 183, 0.18);
  border-radius: 16px;
  font-size: 1rem;
  color: var(--text);
  background: #f7faff;
}

.auth-helper {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.status-block {
  margin: 8px 0 18px;
  padding: 18px 22px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(60, 64, 67, 0.08);
  color: var(--muted);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.emails-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.email-card {
  width: 100%;
  padding: 18px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(60, 64, 67, 0.08);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.12);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  overflow: hidden;
}

.email-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(17, 53, 118, 0.12);
}

.email-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.email-subject,
.email-from,
.email-date {
  display: block;
  width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  overflow: hidden;
}

.email-subject {
  font-size: 1rem;
  font-weight: 700;
  color: #102146;
  margin-bottom: 6px;
}

.email-from {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
}

.email-date {
  font-size: 0.85rem;
  color: var(--accent);
}

.email-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.email-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.email-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  white-space: normal;
  word-break: break-word;
  transition: max-height 220ms ease, opacity 220ms ease;
  border-top: 1px solid rgba(47, 81, 183, 0.12);
  padding-top: 16px;
  margin-top: 12px;
}

.email-snippet,
.email-body {
  overflow-wrap: anywhere;
}

.email-snippet {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-wrap;
}

.email-body p,
.email-body div,
.email-body li,
.email-body blockquote,
.email-body pre {
  margin: 0 0 0.85rem;
}

.email-body a {
  color: var(--accent);
  text-decoration: none;
}

.email-body a:hover {
  text-decoration: underline;
}

.email-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.85rem 0;
  border-radius: 14px;
}

.email-body figure {
  margin: 0;
}

.email-card.expanded .email-body {
  max-height: 1000px;
  opacity: 1;
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid rgba(47, 81, 183, 0.12);
}

.email-card.collapsed .email-body {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.email-card.collapsed .email-snippet {
  display: none;
}

a {
  color: var(--accent);
}

@media (max-width: 760px) {
  .page-shell {
    width: 100%;
    padding: 20px 16px 48px;
  }

  .hero-block {
    flex-direction: column;
    align-items: stretch;
    padding: 22px 20px;
  }

  .button-row {
    justify-content: stretch;
  }

  .refresh-button,
  .secondary-button {
    width: 100%;
    min-width: 0;
  }

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

  .email-card {
    padding: 20px;
  }

  .auth-card {
    padding: 18px;
  }

  .auth-input-row {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .hero-note,
  .subtitle,
  .auth-helper,
  .status-block {
    font-size: 0.95rem;
  }

  .status-block {
    padding: 16px 18px;
  }
}
