
:root {
  --bg: #111218;
  --panel: #191a22;
  --panel2: #20212b;
  --hover: #272833;
  --border: #2c2d38;
  --text: #f3f3f7;
  --muted: #9293a2;
  --accent: #8875ff;
  --accent-hover: #9a8aff;
  --input: #20212b;
}

[data-theme="light"] {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel2: #f0f1f6;
  --hover: #ececf3;
  --border: #e4e5eb;
  --text: #20212b;
  --muted: #777988;
  --accent: #7058ed;
  --accent-hover: #806cf5;
  --input: #f1f2f7;
}

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

body {
  font-family: Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  transition: background .2s, color .2s;
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
  color: inherit;
}

.app {
  display: grid;
  grid-template-columns: 245px minmax(360px, 1fr) minmax(300px, 42%);
  height: 100vh;
}

/* SIDEBAR */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 25px 17px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 7px;
  margin-bottom: 34px;
}

.brand-icon {
  width: 37px;
  height: 37px;
  border-radius: 11px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: white;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -1px;
}

.brand-name span {
  color: var(--muted);
  font-weight: 500;
}

.compose-btn {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  transition: .2s;
}

.compose-btn:hover, .send-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.nav-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 33px 8px 12px;
}

.navigation {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.nav-item:hover, .nav-item.active {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-item i {
  width: 17px;
  text-align: center;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
}

.sidebar-bottom {
  margin-top: auto;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 5px 0;
  border-top: 1px solid var(--border);
}

.avatar {
  width: 35px;
  height: 35px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}

.account-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.account-info strong {
  font-size: 12px;
}

.account-info span {
  color: var(--muted);
  font-size: 10px;
}

/* MAIN */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  height: 75px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumb i {
  font-size: 10px;
}

.breadcrumb strong {
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 9px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  width: clamp(150px, 25vw, 280px);
  color: var(--muted);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
  font-size: 12px;
}

.search-box kbd {
  font-size: 10px;
  white-space: nowrap;
}

.icon-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.mobile-menu {
  display: none;
}

.top-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.mail-area {
  padding: 29px 25px;
  overflow-y: auto;
  flex: 1;
}

.mail-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mail-heading h1 {
  font-size: 23px;
  letter-spacing: -.8px;
}

.mail-heading p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.heading-actions {
  display: flex;
  gap: 5px;
}

.filter-bar {
  display: flex;
  gap: 20px;
  margin-top: 30px;
  border-bottom: 1px solid var(--border);
}

.filter {
  background: none;
  border: none;
  padding: 0 2px 12px;
  color: var(--muted);
  font-size: 12px;
}

.filter.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* EMAIL LIST */

.mail-list {
  margin-top: 9px;
}

.mail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 9px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 5px;
  transition: background .15s;
}

.mail-item:hover, .mail-item.selected {
  background: var(--hover);
}

.mail-item.unread .sender,
.mail-item.unread .subject {
  font-weight: 700;
  color: var(--text);
}

.mail-item:not(.unread) .sender,
.mail-item:not(.unread) .subject {
  color: var(--muted);
}

.mail-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel2);
  font-size: 13px;
  font-weight: 700;
}

.mail-details {
  min-width: 0;
  flex: 1;
}

.mail-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.sender {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.subject {
  font-size: 12px;
  margin-top: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.preview {
  font-size: 10px;
  color: var(--muted);
  margin-top: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.star-btn {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 6px;
}

.star-btn.starred {
  color: #eebd58;
}

/* READER */

.reader {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 30px 24px;
}

.reader-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.reader-empty i {
  font-size: 38px;
  color: var(--muted);
  margin-bottom: 17px;
}

.reader-empty h3 {
  font-size: 15px;
}

.reader-empty p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.reader-content h2 {
  font-size: 19px;
  line-height: 1.5;
  margin-bottom: 23px;
}

.reader-sender {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.reader-sender-info strong {
  font-size: 12px;
}

.reader-sender-info p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}

.reader-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.9;
  margin-top: 25px;
}

.reader-actions {
  display: flex;
  gap: 8px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.reader-actions button {
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 11px;
}

/* EMPTY STATE */

.empty-state {
  text-align: center;
  padding: 75px 15px;
}

.empty-icon {
  color: var(--muted);
  font-size: 35px;
}

.empty-state h3 {
  font-size: 15px;
  margin-top: 17px;
}

.empty-state p {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 20px;
}

.compose-btn.small {
  display: inline-flex;
  padding: 0 18px;
  height: 39px;
}

/* COMPOSE */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #0009;
  z-index: 10;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.modal-backdrop.open {
  display: flex;
}

.compose-window {
  width: 550px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 20px 80px #0005;
}

.compose-header {
  height: 52px;
  background: var(--panel2);
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.compose-header strong {
  font-size: 13px;
}

#composeForm {
  display: flex;
  flex-direction: column;
}

#composeForm input,
#composeForm textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 15px 18px;
  color: var(--text);
  outline: none;
  font-size: 12px;
}

#composeForm textarea {
  min-height: 250px;
  resize: vertical;
  border: none;
  line-height: 1.7;
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.send-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

#draftStatus {
  font-size: 10px;
  color: var(--muted);
  flex: 1;
}

.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 13px 19px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* RESPONSIVE */

@media(max-width: 1050px) {
  .app {
    grid-template-columns: 210px minmax(300px, 1fr);
  }

  .reader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5;
    border: none;
  }

  .reader.mobile-open {
    display: block;
  }
}

@media(max-width: 650px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 245px;
    z-index: 8;
    transition: left .2s;
  }

  .sidebar.open {
    left: 0;
  }

  .topbar {
    padding: 0 13px;
    gap: 8px;
  }

  .mobile-menu {
    display: grid;
  }

  .breadcrumb {
    flex: 1;
    gap: 7px;
  }

  .search-box {
    width: 38px;
    padding: 0 10px;
    border: none;
    background: transparent;
  }

  .search-box input {
    display: none;
  }

  .search-box kbd {
    display: none;
  }

  .top-actions {
    gap: 3px;
  }

  .mail-area {
    padding: 22px 15px;
  }

  .mail-heading h1 {
    font-size: 21px;
  }

  .reader.mobile-open {
    display: block;
  }
}
