/* =========================================================
   Efinder Webmail — Editorial / Warm Human Design
   Adapted from CloudGPU design brief:
   - Warm off-white paper backgrounds
   - Deep muted brown text
   - Serif display + Monospace UI layers
   - Minimal cards, thin borders, generous whitespace
   - Calm, spacious, editorial restraint
   ========================================================= */

:root {
  /* Warm neutral system */
  --bg-page:        #FEF9ED;
  --bg-surface:     #F7F1E3;
  --bg-highlight:   #FBF4E5;
  --bg-inverse:     #5D524B;

  /* Text */
  --text:           #5D524B;
  --text-muted:     rgba(93, 82, 75, 0.68);
  --text-faint:     rgba(93, 82, 75, 0.40);
  --text-inverse:   #F7ECD9;

  /* Borders */
  --border:         rgba(93, 82, 75, 0.22);
  --border-light:   rgba(93, 82, 75, 0.12);
  --border-focus:   rgba(93, 82, 75, 0.45);

  /* Accent — warm brown only, used sparingly */
  --accent-soft:    rgba(93, 82, 75, 0.08);

  /* Feedback */
  --red:            #c44;
  --red-bg:         rgba(204, 68, 68, 0.08);

  /* Typography */
  --font-display:   Source Serif 4, Charter, Iowan Old Style, Georgia, Times New Roman, serif;
  --font-ui:        IBM Plex Mono, Red Hat Mono, SFMono-Regular, Consolas, Courier New, monospace;

  /* Radii — minimal, editorial */
  --radius-sm:      2px;
  --radius:         4px;
  --radius-lg:      8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-page);
  color: var(--text);
  height: 100%;
  font-size: 16px;
  line-height: 1.45;
}
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  z-index: 1000;
  background:
    repeating-linear-gradient(
      135deg,
      #9DDBF5 0 18px,
      #9DDBF5 18px 28px,
      var(--bg-page) 28px 38px,
      var(--bg-page) 38px 48px,
      #F2A38C 48px 66px,
      #F2A38C 66px 76px,
      var(--bg-page) 76px 86px,
      var(--bg-page) 86px 96px
    );
  border-bottom: 1px solid var(--border-light);
  pointer-events: none;
}

.send-magic-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 249, 225, 0.98), rgba(254, 249, 237, 0.56) 28%, rgba(254, 249, 237, 0.08) 68%),
    conic-gradient(from 210deg at 50% 42%, rgba(157,219,245,.28), rgba(243,207,116,.4), rgba(242,163,140,.34), rgba(185,217,139,.28), rgba(157,219,245,.28));
  animation: send-overlay-fade 1.25s ease forwards;
  backdrop-filter: blur(2px);
}
.send-magic-card {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  min-width: 260px;
  padding: 28px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(254, 249, 237, 0.92);
  color: var(--text);
  text-align: center;
  box-shadow: 0 24px 80px rgba(93, 82, 75, 0.18), 0 0 70px rgba(243, 207, 116, 0.35);
  animation: send-card-lift 1.12s cubic-bezier(.2, .8, .2, 1) forwards;
}
.send-magic-card .material-symbols-outlined {
  display: block;
  font-size: 34px;
  margin-bottom: 10px;
  color: var(--text);
}
.send-magic-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.send-magic-card small {
  display: block;
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.send-sparkle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #F3CF74;
  box-shadow:
    0 0 0 1px rgba(93, 82, 75, 0.08),
    0 0 24px rgba(243, 207, 116, 0.95),
    0 0 52px rgba(243, 207, 116, 0.45);
  animation: send-sparkle-pop 1.1s ease var(--delay) forwards;
  opacity: 0;
}
.send-sparkle::before,
.send-sparkle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--size) * 2.4);
  height: 1px;
  background: currentColor;
  transform: translate(-50%, -50%);
  opacity: .65;
}
.send-sparkle::after {
  transform: translate(-50%, -50%) rotate(90deg);
}
.send-sparkle:nth-child(3n) { background: #9DDBF5; }
.send-sparkle:nth-child(4n) { background: #F2A38C; }
.send-sparkle:nth-child(5n) { background: #B9D98B; }
.send-comet {
  position: absolute;
  left: 18vw;
  top: 58vh;
  width: 28vw;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #F3CF74, #FEF9ED);
  box-shadow: 0 0 34px rgba(243, 207, 116, .9);
  transform: rotate(-24deg);
  animation: send-comet-fly 1.05s cubic-bezier(.16, .9, .24, 1) forwards;
}

@keyframes send-overlay-fade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes send-card-lift {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(0.96); }
  16% { opacity: 1; }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -68%) scale(1.02); }
}
@keyframes send-sparkle-pop {
  0% { opacity: 0; transform: translateY(26px) scale(0.25) rotate(0deg); }
  18% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-70px) scale(1.8) rotate(150deg); }
}
@keyframes send-comet-fly {
  0% { opacity: 0; transform: translate(-10vw, 14vh) rotate(-24deg) scaleX(.35); }
  14% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(44vw, -30vh) rotate(-24deg) scaleX(1.1); }
}

/* Material Symbols sizing */
.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
}

/* ---- Scrollbars ---------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---- Selection ----------------------------------------- */
::selection { background: var(--accent-soft); color: var(--text); }

/* ---- Monospace utility layer ---------------------------- */
.mono {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- Buttons ------------------------------------------- */
.btn-primary {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border: 1px solid var(--bg-inverse);
  border-radius: var(--radius);
  padding: 12px 28px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary:hover {
  background: var(--text);
  border-color: var(--text);
}

.btn-secondary {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 22px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.btn-secondary:hover {
  background: var(--bg-highlight);
  border-color: var(--border-focus);
}

.btn-icon {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-icon:hover {
  background: var(--bg-highlight);
  color: var(--text);
}

.btn-compose {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid var(--bg-inverse);
}
.btn-compose:hover {
  background: var(--text);
  border-color: var(--text);
}

.bulk-apply {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-highlight);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  min-height: 38px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.bulk-apply:hover,
.bulk-apply:focus-visible {
  background: var(--bg-inverse);
  border-color: var(--bg-inverse);
  color: var(--text-inverse);
  outline: none;
}

/* ---- Login Page — Editorial full-width ----------------- */
.page-login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-page);
  padding: 48px 32px;
}

.login-editorial {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.login-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 24px;
}

.login-headline {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 20px;
}

.login-lead {
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 48px;
  max-width: 480px;
}

.login-form { text-align: left; }
.login-form .field { margin-bottom: 28px; }
.login-form label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.login-form input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-family: var(--font-display);
  font-size: 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-highlight);
  color: var(--text);
  transition: all 0.2s ease;
}
.login-form input:focus {
  border-color: var(--border-focus);
  background: var(--bg-page);
  outline: none;
}
.login-form input::placeholder {
  color: var(--text-faint);
  font-family: var(--font-display);
}
.login-form .btn-primary {
  width: 100%;
  height: 56px;
  margin-top: 8px;
  font-size: 0.8125rem;
}

.login-error {
  background: var(--red-bg);
  border: 1px solid rgba(204,68,68,0.20);
  color: var(--red);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 28px;
  text-align: left;
}

.login-footer {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---- App Layout ---------------------------------------- */
.app {
  display: flex;
  height: calc(100vh - 10px);
  margin-top: 10px;
  overflow: hidden;
  background: var(--bg-page);
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-mini {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.user-email {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-actions {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.folder-list { flex: 1; overflow-y: auto; padding: 12px 0; }
.folder-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  margin: 2px 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius);
  transition: all 0.12s ease;
}
.folder-icon {
  font-size: 17px;
  color: var(--text-faint);
  transition: color 0.12s ease;
}
.folder-link:hover .folder-icon,
.folder-link.active .folder-icon {
  color: var(--text);
}
.folder-link:hover {
  background: var(--bg-highlight);
  color: var(--text);
}
.folder-link.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.mobile-header,
.mobile-compose-fab,
.sidebar-overlay {
  display: none;
}

/* Message List Pane */
.list-pane {
  width: 400px;
  min-width: 340px;
  max-width: 460px;
  background: var(--bg-page);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.list-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-folder-strip {
  display: none;
}
.list-header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.folder-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.msg-count {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.search-bar input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-highlight);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  color: var(--text);
  transition: all 0.2s ease;
}
.search-bar input:focus {
  border-color: var(--border-focus);
  outline: none;
  background: var(--bg-page);
}
.search-bar input::placeholder {
  color: var(--text-faint);
  font-family: var(--font-display);
}

.bulk-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: stretch;
}
.bulk-menu {
  position: relative;
  flex: 1;
  min-width: 0;
}
.bulk-menu-button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-highlight);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}
.bulk-menu-button:hover,
.bulk-menu.open .bulk-menu-button,
.bulk-menu-button:focus-visible {
  border-color: var(--border-focus);
  background: var(--bg-page);
  color: var(--text);
  outline: none;
}
.bulk-menu-chevron {
  width: 7px;
  height: 7px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.7;
  flex-shrink: 0;
}
.bulk-menu-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-page);
  box-shadow: 0 14px 36px rgba(93, 82, 75, 0.12);
}
.bulk-menu.open .bulk-menu-list {
  display: grid;
  gap: 2px;
}
.bulk-menu-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.bulk-menu-option:hover,
.bulk-menu-option.active {
  background: var(--accent-soft);
}

.message-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.msg-row-wrap {
  position: relative;
  display: block;
  margin: 4px 12px;
  border-radius: var(--radius);
  user-select: none;
}
.msg-row-wrap.selected .msg-row {
  background: var(--bg-highlight);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--bg-inverse);
}
.msg-row-wrap.active-reading .msg-row {
  background: var(--bg-surface);
  border-color: var(--border-focus);
}
.msg-row {
  display: block;
  padding: 18px 24px;
  margin: 0;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.1s ease;
  border: 1px solid transparent;
}
.msg-row:hover {
  background: var(--bg-highlight);
  border-color: var(--border);
}
.msg-row.unread {
  background: var(--bg-page);
  border-color: var(--border-light);
}
.msg-row.unread:hover {
  background: var(--bg-highlight);
}

.msg-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.msg-from {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  padding-right: 12px;
  color: var(--text-muted);
}
.msg-row.unread .msg-from {
  font-weight: 600;
  color: var(--text);
}
.msg-date {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.msg-subj {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.msg-row.unread .msg-subj {
  color: var(--text);
  font-weight: 500;
}

.empty-state {
  padding: 100px 24px;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 1.0625rem;
}
.empty-state .material-symbols-outlined {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--text-faint);
  display: block;
}
.empty-state p {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.list-pager {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pager-btn {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: all 0.1s;
}
.pager-btn:hover {
  background: var(--bg-highlight);
  color: var(--text);
}
.pager-info {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Reading Pane */
.reading-pane {
  flex: 1;
  background: var(--bg-page);
  overflow-y: auto;
  min-width: 0;
}
.reading-pane-full { display: flex; flex-direction: column; }

.reading-toolbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-page);
}
.reading-actions { display: flex; gap: 10px; }
.reading-actions form {
  display: inline-flex;
}

.message-view { padding: 40px 48px; max-width: 780px; }
.msg-view-subject {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}
.msg-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.msg-view-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.msg-view-sender { flex: 1; }
.msg-view-from {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.msg-view-to {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 3px;
}
.msg-view-date {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}

.msg-view-attachments {
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.attachment-chip {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text-muted);
  transition: all 0.15s ease;
  text-decoration: none;
}
.attachment-chip:hover {
  background: var(--bg-surface);
  border-color: var(--border-focus);
  color: var(--text);
}
.attachment-chip:hover {
  background: var(--bg-surface);
  border-color: var(--border-focus);
}

.msg-view-body {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text);
}
.msg-view-body .html-body img {
  display: none;
}
.msg-view-body .html-body a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.msg-view-body .html-body a:hover {
  color: var(--text-muted);
}
.msg-view-body .html-body iframe,
.msg-view-body .html-body object,
.msg-view-body .html-body embed,
.msg-view-body .html-body form,
.msg-view-body .html-body script {
  display: none !important;
}
.msg-view-body .html-body table {
  max-width: 100%;
  border-collapse: collapse;
}
.msg-view-body .html-body td,
.msg-view-body .html-body th {
  border: 1px solid var(--border-light);
  padding: 6px 8px;
  vertical-align: top;
}
.msg-view-body pre.text-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ---- Compose ------------------------------------------- */
.compose-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-page);
}
.compose-toolbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-page);
  position: relative;
  gap: 12px;
}
.compose-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}
.compose-send {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.compose-send-label {
  display: inline;
}
.compose-form { display: flex; flex-direction: column; flex: 1; }
.compose-fields {
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-highlight);
}
.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.compose-field:last-child { border-bottom: none; }
.compose-field label {
  width: 60px;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  flex-shrink: 0;
}
.compose-field input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text);
  padding: 4px 0;
  outline: none;
}
.compose-field input[type="file"] {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.compose-field input::placeholder {
  color: var(--text-faint);
  font-family: var(--font-display);
}
.compose-body {
  flex: 1;
  border: none;
  padding: 28px;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text);
  resize: none;
  outline: none;
  background: var(--bg-page);
}
.compose-body::placeholder {
  color: var(--text-faint);
  font-family: var(--font-display);
}
.compose-error {
  background: var(--red-bg);
  border-bottom: 1px solid rgba(204,68,68,0.18);
  color: var(--red);
  padding: 12px 28px;
  font-family: var(--font-display);
  font-size: 1rem;
}

/* ---- Responsive ---------------------------------------- */
@media screen and (max-width: 768px) {
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .mobile-header-title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-menu-toggle,
  .mobile-header-compose {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
  }
  .mobile-menu-toggle:hover,
  .mobile-header-compose:hover {
    background: var(--bg-highlight);
    color: var(--text);
  }

  .mobile-compose-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 72px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-inverse);
    color: var(--text-inverse);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
    z-index: 40;
    text-decoration: none;
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .mobile-compose-fab:hover,
  .mobile-compose-fab:active {
    background: var(--text);
    transform: scale(1.05);
  }
  .mobile-compose-fab .material-symbols-outlined {
    font-size: 24px;
  }

  .list-pane { width: 100%; border-right: none; }
  .reading-pane { display: none; }
  .page-mail.reading .sidebar { display: none; }
  .page-mail.reading .list-pane { display: none; }
  .page-mail.reading .reading-pane {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .app {
    height: calc(100dvh - 10px);
    min-height: calc(100vh - 10px);
  }

  .list-header {
    padding: 16px 16px 12px;
  }

  .mobile-folder-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 12px;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mobile-folder-strip::-webkit-scrollbar {
    display: none;
  }

  .mobile-folder-chip {
    flex: 0 0 auto;
    padding: 7px 11px;
    border-radius: var(--radius);
    background: var(--bg-highlight);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    transition: all 0.12s ease;
  }

  .mobile-folder-chip:hover {
    background: var(--bg-page);
    color: var(--text);
  }

  .mobile-folder-chip.active {
    background: var(--bg-inverse);
    color: var(--text-inverse);
  }

  .bulk-toolbar {
    display: none;
  }

  .msg-row-wrap {
    margin: 4px 10px;
  }

  .msg-row {
    padding: 16px 16px;
  }

  .msg-row-wrap.selected .msg-row {
    box-shadow: none;
  }

  .reading-toolbar {
    padding: 12px 14px;
    gap: 10px;
    align-items: flex-start;
  }

  .reading-actions {
    gap: 6px;
    overflow-x: auto;
    max-width: calc(100vw - 64px);
    padding-bottom: 4px;
  }

  .reading-actions .btn-secondary {
    padding: 8px 10px;
    font-size: 0.65rem;
  }

  .page-compose {
    min-height: 100%;
    overflow: hidden;
  }

  .page-compose::before {
    position: fixed;
  }

  .compose-wrap {
    height: calc(100dvh - 10px);
    min-height: calc(100vh - 10px);
    margin-top: 10px;
    overflow: hidden;
  }

  .compose-form {
    min-height: 0;
  }

  .compose-toolbar {
    flex-shrink: 0;
    padding: 12px 16px;
    background: var(--bg-page);
    gap: 8px;
  }

  .compose-title {
    font-size: 1rem;
  }

  .compose-send-label {
    display: none;
  }

  .compose-toolbar .btn-primary {
    min-height: 42px;
    padding: 10px 14px;
  }

  .compose-fields {
    flex-shrink: 0;
    padding: 0 16px;
    max-height: 42vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .compose-field {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 10px 0;
  }

  .compose-field label {
    width: auto;
    font-size: 0.625rem;
  }

  .compose-field input {
    min-width: 0;
    width: 100%;
    font-size: 1rem;
  }

  .compose-field input[type="file"] {
    font-size: 0.6875rem;
  }

  .compose-body {
    flex: 1 1 auto;
    min-height: 180px;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    font-size: 1.08rem;
    line-height: 1.5;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .compose-error {
    flex-shrink: 0;
    padding: 10px 16px;
  }
  .page-login { padding: 32px 20px; }
  .login-headline { font-size: 2rem; }
  .message-view { padding: 24px; }
  .msg-view-subject { font-size: 1.5rem; }
}

/* =========================================================
   Landing Page — Editorial marketing page
   ========================================================= */

.page-landing {
  background: var(--bg-page);
  min-height: 100vh;
}

/* Navbar */
.landing-nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  position: sticky;
  top: 0;
  z-index: 10;
}
.landing-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.landing-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}
.landing-nav-links a {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.landing-nav-links a:hover {
  color: var(--text);
}

/* Hero */
.landing-hero {
  padding: 120px 32px 100px;
  border-bottom: 1px solid var(--border);
}
.landing-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.landing-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 24px;
}
.landing-headline {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 24px;
  max-width: 720px;
}
.landing-lead {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 40px;
  max-width: 520px;
}
.landing-hero-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Sections */
.landing-section {
  padding: 100px 32px;
  border-bottom: 1px solid var(--border);
}
.landing-section-alt {
  background: var(--bg-highlight);
}
.landing-section-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.landing-section-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 16px;
}
.landing-section-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 20px;
}
.landing-section-body {
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 560px;
}

/* Cards */
.landing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 48px;
}
.landing-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  background: transparent;
  transition: all 0.15s ease;
}
.landing-card:hover {
  background: var(--bg-highlight);
}
.landing-card-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.landing-card-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.landing-card-body {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* CTA */
.landing-cta {
  text-align: center;
  padding: 80px 32px;
}
.landing-cta-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 32px;
}

/* Footer */
.landing-footer {
  border-top: 1px solid var(--border);
  padding: 48px 32px;
  background: var(--bg-surface);
}
.landing-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}
.landing-footer-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.landing-footer-tagline {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.landing-footer-links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.landing-footer-links a {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.landing-footer-links a:hover {
  color: var(--text);
}

/* Responsive */
@media screen and (max-width: 768px) {
  .landing-headline { font-size: 2.5rem; }
  .landing-section-title { font-size: 2rem; }
  .landing-hero { padding: 80px 24px 60px; }
  .landing-section { padding: 60px 24px; }
  .landing-nav-inner { padding: 14px 20px; }
  .landing-footer-inner { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   Dark mode — warm editorial palette, same aesthetics
   ========================================================= */

html[data-theme="dark"] {
  /* Warm dark neutral system */
  --bg-page:        #1C1916;
  --bg-surface:     #25211D;
  --bg-highlight:   #2F2A25;
  --bg-inverse:     #E8DCC8;

  /* Text */
  --text:           #E8DCC8;
  --text-muted:     rgba(232, 220, 200, 0.72);
  --text-faint:     rgba(232, 220, 200, 0.42);
  --text-inverse:   #1C1916;

  /* Borders */
  --border:         rgba(232, 220, 200, 0.16);
  --border-light:   rgba(232, 220, 200, 0.10);
  --border-focus:   rgba(232, 220, 200, 0.40);

  /* Accent */
  --accent-soft:    rgba(232, 220, 200, 0.10);

  /* Feedback */
  --red:            #E57373;
  --red-bg:         rgba(229, 115, 115, 0.12);
}

html[data-theme="dark"] ::selection {
  background: var(--accent-soft);
  color: var(--text);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--border);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* Send overlay dark variant */
html[data-theme="dark"] .send-magic-overlay {
  background:
    radial-gradient(circle at 50% 42%, rgba(37, 33, 29, 0.98), rgba(28, 25, 22, 0.56) 28%, rgba(28, 25, 22, 0.08) 68%),
    conic-gradient(from 210deg at 50% 42%, rgba(157,219,245,.22), rgba(243,207,116,.32), rgba(242,163,140,.28), rgba(185,217,139,.22), rgba(157,219,245,.22));
}
html[data-theme="dark"] .send-magic-card {
  background: rgba(37, 33, 29, 0.92);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), 0 0 70px rgba(243, 207, 116, 0.22);
}
html[data-theme="dark"] .send-comet {
  background: linear-gradient(90deg, transparent, #F3CF74, #1C1916);
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 22px rgba(0,0,0,0.12);
  transition: all 0.2s ease;
}
.theme-toggle:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg-highlight);
}
.theme-toggle .material-symbols-outlined {
  font-size: 22px;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
html[data-theme="dark"] .theme-toggle-icon-light,
.theme-toggle-icon-dark {
  opacity: 0;
  transform: scale(0.8);
}
html[data-theme="light"] .theme-toggle-icon-light,
html:not([data-theme]) .theme-toggle-icon-light {
  opacity: 1;
  transform: scale(1);
}
html[data-theme="dark"] .theme-toggle-icon-dark {
  opacity: 1;
  transform: scale(1);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle .material-symbols-outlined {
    transition: none;
  }
}

/* =========================================================
   Composer enhancements — rich text, drafts, attachments
   ========================================================= */

.compose-format-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-top: 10px;
}
.compose-format-bar.open {
  display: inline-flex;
}
.compose-format-bar .btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
}
.compose-format-bar .btn-icon:hover,
.compose-format-bar .btn-icon.active {
  background: var(--bg-page);
  color: var(--text);
}
.compose-format-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.compose-draft-status {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-right: 12px;
}
.compose-draft-status.visible {
  opacity: 1;
}

.compose-to-field {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 8px;
  align-items: center;
}
.compose-cc-toggle {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.15s ease;
}
.compose-cc-toggle:hover {
  color: var(--text);
}
.compose-cc-field {
  display: none;
}
.compose-cc-field.expanded {
  display: flex;
}

.compose-extras {
  border-bottom: 1px solid var(--border);
  background: var(--bg-highlight);
  padding: 10px 28px;
}
.compose-extras-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.compose-extra-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}
.compose-extra-btn:hover,
.compose-extra-btn.active {
  background: var(--bg-page);
  color: var(--text);
}
.compose-extra-btn .material-symbols-outlined {
  font-size: 18px;
}
.compose-attachment-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.compose-attachment-area.drag-over .compose-attachment-drop {
  background: var(--bg-page);
  color: var(--text);
}
.compose-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}
.compose-attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-page);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  max-width: 100%;
}
.compose-attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.compose-attachment-size {
  color: var(--text-faint);
  white-space: nowrap;
}
.compose-attachment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  transition: color 0.15s ease;
}
.compose-attachment-remove:hover {
  color: var(--red);
}
.compose-attachment-remove .material-symbols-outlined {
  font-size: 16px;
}

/* contenteditable placeholder */
.compose-body:empty:before {
  content: attr(placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

/* Dark mode composer adjustments */
html[data-theme="dark"] .compose-extra-btn:hover,
html[data-theme="dark"] .compose-extra-btn.active,
html[data-theme="dark"] .compose-format-bar .btn-icon:hover,
html[data-theme="dark"] .compose-format-bar .btn-icon.active,
html[data-theme="dark"] .compose-attachment-area.drag-over .compose-attachment-drop {
  background: var(--bg-highlight);
  color: var(--text);
}
html[data-theme="dark"] .compose-attachment-item {
  background: var(--bg-surface);
}

/* Mobile composer adjustments */
@media screen and (max-width: 768px) {
  .compose-extras {
    padding: 10px 16px;
  }
  .compose-format-bar {
    display: none;
    padding-top: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
  }
  .compose-format-bar.open {
    display: inline-flex;
  }
  .compose-format-bar::-webkit-scrollbar {
    display: none;
  }
  .compose-format-bar .btn-icon {
    width: 34px;
    height: 34px;
  }
  .compose-to-field {
    grid-template-columns: 50px 1fr auto;
  }
  .compose-cc-toggle {
    font-size: 0.625rem;
  }
  .compose-extra-btn {
    padding: 8px 12px;
    font-size: 0.6875rem;
  }
  .compose-attachment-list {
    padding-top: 10px;
  }
  .compose-attachment-name {
    max-width: 150px;
  }
}
