/* === Reset & Variables === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --topbar-height: 64px;
  --sidebar-width: 256px;
  --bg: #f6f8fc;
  --surface: #fff;
  --text-primary: #1f1f1f;
  --text-secondary: #5f6368;
  --text-light: #80868b;
  --border: #e0e0e0;
  --hover: #edf2fc;
  --active-nav: #d3e3fd;
  --active-nav-text: #001d35;
  --compose-bg: #c2e7ff;
  --compose-hover: #a8d8f0;
  --star-gold: #f4b400;
  --star-outline: #80868b;
  --blue: #4285f4;
  --red: #ea4335;
  --green: #34a853;
  --section-divider: #dadce0;
  --search-bg: #eaf1fb;
  --search-focus-bg: #fff;
  --read-bg: transparent;
  --unread-bg: #fff;
  --font-body: 'Roboto', sans-serif;
  --font-display: 'Google Sans', 'Roboto', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  overflow: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #c1c1c1 transparent;
}

/* === Focus Visible === */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.icon-btn:focus-visible,
.star-btn:focus-visible,
.nav-item:focus-visible,
.compose-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.email-row:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: var(--hover);
}

/* === Top Bar === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--bg);
  z-index: 100;
  gap: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 240px;
  gap: 4px;
}

.topbar-center {
  flex: 1;
  max-width: 720px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  padding: 4px 8px;
}

.logo-icon {
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: -0.5px;
}

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--search-bg);
  border-radius: 28px;
  padding: 0 16px;
  height: 48px;
  transition: background 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
  background: var(--search-focus-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
}

.search-icon {
  color: var(--text-secondary);
  margin-right: 12px;
  font-size: 22px;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-secondary);
}

/* Icon & Avatar buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.06);
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
}

/* === Main Layout === */
.main-layout {
  display: flex;
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  padding: 8px 12px 8px 0;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width 0.2s, min-width 0.2s;
}

.sidebar.collapsed {
  width: 72px;
  min-width: 72px;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--compose-bg);
  border: none;
  border-radius: 16px;
  padding: 16px 24px;
  margin: 0 0 12px 12px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.compose-btn:hover {
  background: var(--compose-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.compose-btn .material-symbols-outlined {
  font-size: 24px;
}

.sidebar.collapsed .compose-btn {
  justify-content: center;
  padding: 16px;
  margin-left: 12px;
  margin-right: 0;
  border-radius: 16px;
  width: 56px;
  height: 56px;
}

.sidebar.collapsed .compose-label {
  display: none;
}

/* Nav items */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 32px;
  border-radius: 0 16px 16px 0;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
  position: relative;
}

.nav-item .material-symbols-outlined {
  font-size: 20px;
}

.nav-item:hover {
  background: var(--hover);
}

.nav-item.active {
  background: var(--active-nav);
  color: var(--active-nav-text);
  font-weight: 700;
}

.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  margin-left: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  gap: 0;
}

/* === Content === */
.content {
  flex: 1;
  background: var(--surface);
  border-radius: 16px 0 0 0;
  overflow-y: auto;
  min-width: 0;
}

/* === Inbox Toolbar === */
.inbox-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
  border-radius: 16px 0 0 0;
}

.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}

.checkbox-wrap:hover {
  background: rgba(0,0,0,0.06);
}

.checkbox-wrap input {
  display: none;
}

.checkbox-wrap .checkmark {
  color: var(--text-secondary);
  font-size: 20px;
}

/* === Email Sections === */
.email-section {
  border-bottom: 1px solid var(--section-divider);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  transition: background 0.15s;
}

.section-header:hover {
  background: var(--hover);
}

.section-caret {
  font-size: 18px !important;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.section-header.collapsed .section-caret {
  transform: rotate(-90deg);
}

.section-body {
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.section-body.collapsed {
  max-height: 0 !important;
  overflow: hidden;
}

/* === Email Row === */
.email-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.1s;
  gap: 0;
}

.email-row:hover {
  background: var(--hover);
  box-shadow: inset 0 -1px 0 var(--border);
}

.email-row.unread {
  background: var(--unread-bg);
}

.email-row .checkbox-wrap {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.email-row .checkbox-wrap .checkmark {
  font-size: 18px;
}

/* Star */
.star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}

.star-btn:hover {
  background: rgba(0,0,0,0.06);
}

.star-btn .material-symbols-outlined {
  font-size: 20px;
  color: var(--star-outline);
}

.star-btn.starred .material-symbols-outlined {
  color: var(--star-gold);
  font-variation-settings: 'FILL' 1;
}

/* Email row content */
.email-sender {
  width: 200px;
  min-width: 200px;
  padding: 0 8px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row.unread .email-sender {
  font-weight: 700;
}

.email-content {
  flex: 1;
  display: flex;
  align-items: baseline;
  min-width: 0;
  padding-right: 8px;
  overflow: hidden;
}

.email-subject-line {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-row.unread .email-subject-line {
  font-weight: 700;
}

/* Row avatar (hidden on desktop, shown on mobile) */
.email-row-avatar {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  flex-shrink: 0;
}

.email-preview {
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.email-preview::before {
  content: ' — ';
  color: var(--text-light);
}

.email-row-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 8px;
  white-space: nowrap;
}

.email-row.unread .email-row-date {
  font-weight: 700;
  color: var(--text-primary);
}

/* === Ad Row === */
.ad-row {
  text-decoration: none;
  color: var(--text-primary);
  background: #fef7e0;
  border-left: 4px solid #f4b400;
}

.ad-row:hover {
  background: #fdf0c4;
}

.ad-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #34a853;
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  margin-right: 4px;
}

.ad-row .email-sender {
  font-weight: 700;
}

.ad-row .email-subject-line {
  font-weight: 700;
}

.ad-inline-cta {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 8px;
  transition: background 0.15s, color 0.15s;
}

.ad-row:hover .ad-inline-cta {
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
}

.ad-section {
  border-bottom: none;
}

/* === In-Email Ad (compact banner) === */
.email-ad {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.email-ad-card-wrap {
  position: relative;
}

.email-ad-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 44px 10px 12px;
  background: #fef7e0;
  border: 1px solid #f0e6b8;
  border-left: 4px solid #f4b400;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
  cursor: pointer;
  overflow: hidden;
}

.email-ad-card:hover {
  background: #fdf0c4;
}

.email-ad-card .ad-badge {
  flex-shrink: 0;
}

.email-ad-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #34a853;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.email-ad-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.email-ad-cta {
  font-size: 12px;
  font-weight: 500;
  color: var(--blue);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.email-ad-cta:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.email-ad-close {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  z-index: 1;
}

.email-ad-close:hover {
  background: rgba(0,0,0,0.08);
  color: var(--text-primary);
}

.email-ad.dismissed {
  display: none;
}

/* === Inbox Footer === */
.inbox-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-light);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  padding: 8px 2px;
}

.footer-links a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.footer-dot {
  color: var(--text-light);
}

.footer-activity {
  text-align: right;
  line-height: 1.5;
}

.footer-activity a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.footer-activity a:hover {
  text-decoration: underline;
}

/* === Empty State === */
.no-results {
  display: none;
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.no-results .material-symbols-outlined {
  display: block;
  font-size: 48px;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* === View Transitions === */
.inbox-view,
.email-view {
  animation: viewFadeIn 0.15s ease-out;
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Email Read View === */
.email-view {
  padding: 0;
}

.email-view-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
  border-radius: 16px 0 0 0;
}

.email-view-content {
  max-width: 860px;
  padding: 24px 32px 48px;
}

.email-subject {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 24px;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: break-word;
}

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

.email-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  flex-shrink: 0;
}

.email-meta-text {
  flex: 1;
  min-width: 0;
}

.email-meta-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.email-sender-name {
  font-weight: 500;
  font-size: 14px;
}

.email-sender-addr {
  font-size: 12px;
  color: var(--text-secondary);
}

.email-meta-bottom {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.email-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Email body content */
.email-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
}

.email-body p {
  margin-bottom: 16px;
}

.email-body h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  margin: 28px 0 12px;
}

.email-body h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 8px;
}

.email-body ul, .email-body ol {
  margin: 8px 0 16px 24px;
}

.email-body li {
  margin-bottom: 6px;
}

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

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

.email-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.email-body .signature {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

.email-body .cta-btn {
  display: inline-block;
  background: var(--blue);
  color: #fff !important;
  padding: 10px 24px;
  border-radius: 4px;
  font-weight: 500;
  margin: 12px 0;
  text-decoration: none !important;
}

.email-body .highlight {
  background: #fef7cd;
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
}

.email-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.email-body th, .email-body td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.email-body th {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Sidebar overlay backdrop === */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}

.sidebar-backdrop.visible {
  display: block;
}

/* === Responsive: Tablet === */
@media (max-width: 1024px) {
  .sidebar {
    width: 72px;
    min-width: 72px;
  }
  .sidebar .nav-label,
  .sidebar .nav-count {
    display: none;
  }
  .sidebar .nav-item {
    justify-content: center;
    padding: 0;
    margin-left: 12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    gap: 0;
  }
  .sidebar .compose-btn {
    justify-content: center;
    padding: 16px;
    margin-left: 12px;
    margin-right: 0;
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }
  .sidebar .compose-label {
    display: none;
  }
  .email-sender {
    width: 140px;
    min-width: 140px;
  }
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {

  :root {
    --topbar-height: 56px;
  }

  /* --- Top bar --- */
  .topbar {
    padding: 0 4px;
    height: 56px;
    gap: 4px;
  }
  .topbar-left {
    min-width: auto;
    gap: 0;
  }
  .logo-text {
    display: none;
  }
  .topbar-center {
    margin: 0 4px;
  }
  .search-bar {
    height: 44px;
    padding: 0 14px;
    border-radius: 24px;
  }
  .search-bar input {
    font-size: 15px;
  }
  .topbar-right .icon-btn {
    display: none;
  }
  .topbar-right .avatar-btn {
    margin-left: 4px;
  }

  /* --- Layout --- */
  .main-layout {
    margin-top: 56px;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
  }

  /* --- Sidebar: full overlay drawer --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    min-width: 300px;
    background: var(--surface);
    z-index: 200;
    padding: 16px 16px 16px 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    overflow-y: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
  }

  /* Override collapsed desktop state — drawer always renders full */
  .sidebar.collapsed {
    width: 300px;
    min-width: 300px;
  }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-count {
    display: inline;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 0 24px;
    margin-left: 0;
    width: auto;
    height: 40px;
    border-radius: 0 16px 16px 0;
    gap: 20px;
  }
  .sidebar.collapsed .compose-btn {
    width: auto;
    height: auto;
    padding: 16px 24px;
    margin-left: 12px;
    border-radius: 16px;
  }
  .sidebar.collapsed .compose-label {
    display: inline;
  }

  /* Bigger touch targets for nav items */
  .nav-item {
    height: 40px;
    font-size: 14px;
  }

  /* --- Content area --- */
  .content {
    border-radius: 0;
  }
  .inbox-toolbar {
    border-radius: 0;
    padding: 2px 4px;
  }
  .email-view-toolbar {
    border-radius: 0;
  }

  /* --- Email rows: Gmail mobile 3-line style --- */
  .email-row {
    height: auto;
    padding: 12px 16px 12px 16px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 12px;
    align-items: start;
    border-bottom: 1px solid var(--section-divider);
    box-shadow: none;
  }

  .email-row:hover {
    box-shadow: none;
  }

  /* Hide desktop checkbox */
  .email-row .checkbox-wrap {
    display: none;
  }

  /* Show row avatar */
  .email-row-avatar {
    display: flex;
    grid-row: 1 / 3;
    grid-column: 1;
    margin-top: 2px;
  }

  /* Hide desktop star on rows (declutter) */
  .email-row .star-btn {
    grid-row: 1;
    grid-column: 3;
    width: 44px;
    height: 44px;
    margin: 0;
  }
  .email-row .star-btn .material-symbols-outlined {
    font-size: 18px;
  }

  /* Sender + date line */
  .email-sender {
    grid-row: 1;
    grid-column: 2;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0;
    font-size: 14px;
    line-height: 20px;
  }

  .email-row-date {
    display: none;
  }

  /* Subject + preview on second line */
  .email-content {
    grid-row: 2;
    grid-column: 2 / 4;
    padding: 2px 0 0 0;
    display: block;
    overflow: hidden;
  }

  .email-subject-line {
    display: block;
    font-size: 13px;
    line-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .email-preview {
    display: block;
    font-size: 13px;
    line-height: 18px;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .email-preview::before {
    content: '';
  }

  /* --- Ad row mobile --- */
  .ad-row {
    grid-template-columns: 40px 1fr auto;
    border-left: 4px solid #f4b400;
  }
  .ad-row .ad-badge {
    grid-row: 1;
    grid-column: 3;
    align-self: center;
    margin-right: 0;
  }
  .ad-row .ad-inline-cta {
    grid-row: 3;
    grid-column: 2 / 4;
    justify-self: start;
    margin-left: 0;
    margin-top: 6px;
  }
  .ad-row .ad-avatar {
    display: flex;
  }
  .ad-row .email-sender {
    grid-row: 1;
    grid-column: 2;
  }
  .ad-row .email-content {
    grid-row: 2;
    grid-column: 2 / 4;
  }
  .ad-row .email-row-date {
    display: none;
  }

  /* --- Section headers --- */
  .section-header {
    padding: 10px 16px;
    font-size: 13px;
  }

  /* --- Footer --- */
  .inbox-footer {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
  }
  .footer-activity {
    text-align: center;
  }

  /* --- Email read view --- */
  .email-view-content {
    padding: 20px 16px 40px;
  }

  .email-subject {
    font-size: 20px;
    line-height: 1.35;
    margin-bottom: 20px;
  }

  .email-meta {
    gap: 10px;
  }

  .email-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .email-sender-name {
    font-size: 14px;
  }

  .email-sender-addr {
    display: none;
  }

  .email-date {
    font-size: 12px;
  }

  .email-body {
    font-size: 15px;
    line-height: 1.65;
  }

  .email-body h2 {
    font-size: 17px;
    margin: 24px 0 10px;
  }

  .email-body h3 {
    font-size: 15px;
    margin: 20px 0 8px;
  }

  .email-body .cta-btn {
    display: block;
    text-align: center;
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 8px;
  }

  /* Tables scroll horizontally on mobile */
  .email-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .email-body th, .email-body td {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .email-body .highlight {
    padding: 14px;
    font-size: 14px;
  }

  .email-body blockquote {
    margin: 12px 0;
    padding-left: 12px;
    font-size: 14px;
  }

  .email-body .signature {
    font-size: 12px;
    margin-top: 28px;
    padding-top: 14px;
  }

  /* --- In-email ad mobile --- */
  .email-ad {
    margin-top: 24px;
    padding-top: 16px;
  }

  .email-ad-card {
    flex-wrap: wrap;
    padding: 10px 44px 10px 10px;
    gap: 8px;
  }

  .email-ad-text {
    font-size: 12px;
    flex-basis: 100%;
    order: 4;
  }

  .email-ad-cta {
    font-size: 12px;
    padding: 10px 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    flex-basis: 100%;
    justify-content: center;
    order: 5;
  }

  .email-ad-close {
    width: 44px;
    height: 44px;
    font-size: 20px;
    right: 0;
  }
}

/* === Extra small screens (iPhone SE, etc.) === */
@media (max-width: 380px) {
  .topbar {
    padding: 0 2px;
  }
  .search-bar {
    height: 40px;
    padding: 0 10px;
  }
  .search-bar input {
    font-size: 14px;
  }
  .email-row {
    padding: 10px 12px;
    gap: 0 10px;
  }
  .email-row-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .email-view-content {
    padding: 16px 12px 32px;
  }
  .email-subject {
    font-size: 18px;
  }
  .email-body {
    font-size: 14px;
  }
  .email-ad-card {
    padding: 8px 40px 8px 8px;
    gap: 6px;
  }
  .email-ad-avatar {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
  .email-ad-text {
    font-size: 11px;
  }
}
