:root {
  --bg0: #06080d;
  --bg1: #0a0f18;
  --panel0: rgba(17, 24, 38, 0.84);
  --panel1: rgba(12, 18, 29, 0.92);
  --line: rgba(132, 171, 214, 0.18);
  --line2: rgba(132, 171, 214, 0.28);
  --text: #e6edf5;
  --muted: #98aec6;
  --accent: #31a2ff;
  --accent-2: #1f7ecb;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.55);
  --shadow2: 0 10px 28px rgba(0, 0, 0, 0.35);
  --radius-lg: 16px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", Avenir, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(1200px 700px at 10% 6%, rgba(49, 162, 255, 0.18), rgba(0, 0, 0, 0) 58%),
    radial-gradient(circle at 15% 0%, #16273e 0%, #0b1220 45%, var(--bg0) 100%);
}

.shell { min-height: 100vh; }
.hidden { display: none !important; }

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel0), var(--panel1));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.muted { color: var(--muted); }
.error { color: #ff8d8d; min-height: 1.2rem; }
.full { width: 100%; }

button, input, textarea { font: inherit; color: inherit; }

button {
  border: 1px solid rgba(132, 171, 214, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(26, 43, 64, 0.78), rgba(17, 28, 45, 0.92));
  color: var(--text);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, var(--shadow2);
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease;
}

button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary:hover { filter: brightness(1.04); }

button:active { transform: translateY(1px); }

:focus-visible {
  outline: 3px solid rgba(49, 162, 255, 0.72);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.primary {
  background: linear-gradient(180deg, rgba(49, 162, 255, 0.95), rgba(31, 126, 203, 0.78));
  border: none;
  color: #07121e;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 0 rgba(255,255,255,0.28) inset, 0 18px 55px rgba(49, 162, 255, 0.12);
}

.loginScreen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.loginCard {
  width: min(460px, 100%);
  background: linear-gradient(180deg, var(--panel0), var(--panel1));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.loginCard h1 { margin: 0; }
.loginCard p { margin: 0.5rem 0 1rem; color: var(--muted); }

.loginForm label { display: block; margin-top: 0.75rem; color: var(--muted); }
.loginForm input {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(132, 171, 214, 0.25);
  background: rgba(10, 18, 30, 0.72);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset;
}
.loginForm input:focus {
  outline: none;
  border-color: rgba(49, 162, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 0 0 4px rgba(49, 162, 255, 0.16);
}

.loginForm button { margin-top: 0.9rem; width: 100%; }

.mailApp {
  max-width: 1500px;
  margin: 1rem auto;
  padding: 0 1rem 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 260px 1fr 1.4fr;
  grid-template-areas: "sidebar list reader";
}

.sidebar { grid-area: sidebar; padding: 1rem; }
.sidebar h2 { margin: 0; }
.sidebar .folders { margin-top: 1rem; display: grid; gap: 0.5rem; }
.sidebar .folder {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar .folder.active {
  border-color: var(--accent);
  background: #18314f;
}
.sidebarActions { margin-top: 1rem; display: grid; gap: 0.5rem; }

.listPanel { grid-area: list; padding: 1rem; }
.toolbar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.75rem; }
.toolbar input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #2e4663;
  background: #0f1a2a;
}

.messageList {
  display: grid;
  gap: 0.55rem;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 0.2rem;
}

.messageItem {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  background: #112033;
  cursor: pointer;
}

.messageItem:hover { border-color: #3f6186; }
.messageItem.active { border-color: var(--accent); background: #19314d; }
.messageItem.unread { border-left: 5px solid var(--accent); }

.messageItem h4 { margin: 0; font-size: 0.98rem; }
.messageMeta { margin: 0.25rem 0; color: var(--muted); font-size: 0.86rem; }
.messagePreview { margin: 0.15rem 0 0; color: #b9c9db; font-size: 0.9rem; }

.reader { grid-area: reader; padding: 1rem; display: flex; flex-direction: column; min-height: 70vh; }
.readerHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; }
.readerTitle h3 { margin: 0; }
.readerMeta { margin-top: 0.25rem; font-size: 0.9rem; }
.readerActions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.readerBody {
  margin: 0.9rem 0 0;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e1725;
  padding: 0.85rem;
  overflow: auto;
  flex: 1;
}

.composeDialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1725;
  color: var(--text);
  width: min(760px, calc(100vw - 2rem));
}

.composeDialog::backdrop { background: rgba(0, 0, 0, 0.55); }

.composeForm { padding: 1rem; }
.composeForm h3 { margin-top: 0; }
.composeForm label { display: block; margin-top: 0.65rem; color: var(--muted); }
.composeForm input, .composeForm textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #2e4663;
  background: #0f1a2a;
}
.composeActions { margin-top: 0.9rem; display: flex; justify-content: flex-end; gap: 0.55rem; }

@media (max-width: 1100px) {
  .mailApp {
    grid-template-columns: 1fr;
    grid-template-areas: "sidebar" "list" "reader";
  }
  .messageList { max-height: 42vh; }
  .reader { min-height: 45vh; }
}


.brand { display: flex; justify-content: center; margin: 0.25rem 0 0.85rem; }
.brand-sm { justify-content: flex-start; margin: 0 0 0.6rem; }
.logo { width: min(560px, 100%); height: auto; max-height: 88px; display: block; filter: none; }
.brand-sm .logo { width: min(220px, 58vw); max-height: 44px; }


.readerBodyHtml {
  white-space: normal;
  background: #eef2f7;
  color: #0f1b2d;
}

.readerBodyHtml a {
  color: #1f7ecb;
}

.readerBodyHtml img {
  max-width: 100%;
  height: auto;
}
