:root {
  --app-bg: #eef2f7;
  --pane: #ffffff;
  --accent: #0d6efd;
  --list-w: min(400px, 38vw);
  --radius: 1rem;
}

html, body {
  height: 100%;
  background: var(--app-bg);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

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

.top-nav {
  background: linear-gradient(135deg, #0d6efd 0%, #3b82f6 55%, #6366f1 100%);
  border: 0;
  box-shadow: 0 8px 24px rgba(13, 110, 253, 0.22);
}

.top-nav .navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--list-w) 1fr;
  gap: 1rem;
  padding: 1rem;
}

.pane {
  background: var(--pane);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-header {
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.mail-scroll {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.mail-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  transition: background .15s ease, transform .15s ease;
  position: relative;
}

.mail-item:hover {
  background: #f8fafc;
}

.mail-item.active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.mail-item.unread::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 1.25rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}

.from-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.from-name {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-date {
  color: #64748b;
  font-size: 0.75rem;
  white-space: nowrap;
}

.subject-line {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-line {
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reading-empty {
  margin: auto;
  text-align: center;
  color: #64748b;
  padding: 2rem;
}

.reading-empty .icon-circle {
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
  background: #eff6ff;
  color: var(--accent);
  font-size: 1.5rem;
}

.reading-header {
  padding: 1.25rem 1.35rem 1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.reading-body {
  padding: 1.25rem 1.35rem 2rem;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  line-height: 1.6;
}

.reading-body.plain { white-space: pre-wrap; word-break: break-word; }
.reading-body.html-body img { max-width: 100%; height: auto; border-radius: 0.5rem; }

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
}

.btn-pill { border-radius: 999px !important; }
.sync-toast {
  font-size: 0.8rem;
  border-radius: 999px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top right, rgba(99,102,241,.25), transparent 40%),
    radial-gradient(circle at bottom left, rgba(13,110,253,.2), transparent 45%),
    var(--app-bg);
}

.login-card {
  width: min(420px, 100%);
  border: 0;
  border-radius: 1.25rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

@media (max-width: 900px) {
  :root { --list-w: 100%; }
  .workspace {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }
  .workspace.show-reading .list-pane { display: none; }
  .workspace:not(.show-reading) .reading-pane { display: none; }
}
