:root {
  --app-bg: #08110d;
  --app-bg-2: #0d1712;
  --pane: #111c16;
  --pane-2: #15231b;
  --pane-3: #0f1914;
  --line: rgba(154, 255, 191, 0.10);
  --line-strong: rgba(154, 255, 191, 0.18);
  --text: #e8f6ee;
  --muted: #8da89a;
  --accent: #57d37b;
  --accent-2: #8dff9f;
  --accent-soft: rgba(87, 211, 123, 0.12);
  --danger: #ff7a7a;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
  --list-w: min(430px, 40vw);
  --radius: 1.1rem;
}

html, body {
  height: 100%;
  background:
    radial-gradient(circle at top right, rgba(87, 211, 123, 0.12), transparent 28%),
    radial-gradient(circle at bottom left, rgba(37, 87, 56, 0.24), transparent 30%),
    linear-gradient(180deg, var(--app-bg) 0%, var(--app-bg-2) 100%);
}

body {
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

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

.top-nav {
  background: linear-gradient(135deg, rgba(10, 22, 16, 0.92), rgba(17, 37, 26, 0.95));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.top-nav .navbar-brand {
  color: var(--accent-2);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.top-actions .btn,
.top-actions .badge {
  white-space: nowrap;
}

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

.pane {
  background: linear-gradient(180deg, rgba(17, 28, 22, 0.96), rgba(13, 21, 17, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-header {
  padding: 1rem 1.1rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 35, 27, 0.95), rgba(16, 27, 21, 0.95));
}

.section-title,
.reading-title {
  color: var(--text);
}

.section-subtitle,
.empty-state,
.reading-empty,
.mail-date,
.preview-line {
  color: var(--muted) !important;
}

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

.mail-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(154, 255, 191, 0.06);
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
  position: relative;
  background: transparent;
}

.mail-item:hover {
  background: rgba(87, 211, 123, 0.06);
}

.mail-item.active {
  background: linear-gradient(90deg, rgba(87, 211, 123, 0.14), rgba(87, 211, 123, 0.06));
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.mail-item.unread::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 1.3rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(141, 255, 159, 0.55);
}

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

.from-name,
.subject-line {
  color: var(--text);
}

.from-name,
.subject-line,
.preview-line {
  overflow: hidden;
  text-overflow: ellipsis;
}

.from-name,
.subject-line {
  white-space: nowrap;
}

.preview-line {
  margin-top: 0.24rem;
  font-size: 0.82rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.reading-empty .icon-circle {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
  background: rgba(87, 211, 123, 0.12);
  color: var(--accent-2);
  font-size: 1.5rem;
  border: 1px solid var(--line-strong);
}

.reading-header {
  padding: 1.25rem 1.35rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 35, 27, 0.92), rgba(15, 25, 20, 0.95));
}

.reading-body {
  padding: 1.25rem 1.35rem 2rem;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  line-height: 1.7;
  color: var(--text);
}

.reading-body.plain {
  white-space: pre-wrap;
  word-break: break-word;
}

.reading-body.html-body {
  color: var(--text);
}

.reading-body.html-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}

.reading-body.html-body a {
  color: var(--accent-2);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  background: rgba(87, 211, 123, 0.08);
  border: 1px solid rgba(87, 211, 123, 0.12);
  color: #cfe9d8;
  font-size: 0.8rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
}

.btn-pill { border-radius: 999px !important; }

.btn-top {
  background: rgba(87, 211, 123, 0.08);
  border: 1px solid rgba(141, 255, 159, 0.16);
  color: var(--text);
}

.btn-top:hover,
.btn-folder:hover,
.btn-search:hover,
.btn-search-clear:hover {
  background: rgba(87, 211, 123, 0.16);
  border-color: rgba(141, 255, 159, 0.28);
  color: #fff;
}

.btn-compose {
  background: linear-gradient(135deg, #4bc86e, #7dff8e);
  border: 0;
  color: #041009;
}

.btn-compose:hover {
  background: linear-gradient(135deg, #56d97a, #95ffaf);
  color: #041009;
}

.btn-folder,
.btn-search-clear,
.btn-search {
  background: rgba(87, 211, 123, 0.06);
  border: 1px solid rgba(141, 255, 159, 0.14);
  color: var(--text);
}

.btn-folder-active {
  background: linear-gradient(135deg, rgba(87, 211, 123, 0.24), rgba(87, 211, 123, 0.12));
  border: 1px solid rgba(141, 255, 159, 0.28);
  color: #f4fff7;
}

.sync-toast {
  font-size: 0.8rem;
  border-radius: 999px;
  background: rgba(87, 211, 123, 0.08) !important;
  color: #d8f3df !important;
  border: 1px solid rgba(141, 255, 159, 0.16);
}

.dark-alert {
  background: rgba(87, 211, 123, 0.12);
  border: 1px solid rgba(141, 255, 159, 0.16);
  color: #d9f8df;
}

.search-wrap {
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(141, 255, 159, 0.16);
  background: rgba(8, 17, 13, 0.8);
}

.search-icon,
.search-input,
.btn-search,
.btn-search-clear {
  border: 0 !important;
}

.search-icon {
  background: transparent;
  color: var(--accent-2);
}

.search-input {
  background: transparent;
  color: var(--text);
  box-shadow: none !important;
}

.search-input::placeholder {
  color: #789281;
}

.search-input:focus {
  background: transparent;
  color: var(--text);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top right, rgba(87, 211, 123, 0.18), transparent 35%),
    radial-gradient(circle at bottom left, rgba(37, 87, 56, 0.3), transparent 40%),
    var(--app-bg);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(18, 28, 22, 0.98), rgba(13, 21, 17, 0.98));
}

.login-card .text-secondary,
.login-card .form-label {
  color: var(--muted) !important;
}

.login-card .form-control {
  background: rgba(8, 17, 13, 0.75);
  border: 1px solid rgba(141, 255, 159, 0.14);
  color: var(--text);
}

.login-card .form-control:focus {
  background: rgba(8, 17, 13, 0.85);
  border-color: rgba(141, 255, 159, 0.28);
  color: var(--text);
  box-shadow: 0 0 0 .2rem rgba(87, 211, 123, 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; }
}
