:root {
  --bg: #f5f3ff;
  --bg-card: #ffffff;
  --bg-panel: #eeeaf8;
  --border: #d8d4e8;
  --border-hover: #c0bbd5;
  --text: #1a1a1a;
  --text-secondary: #5a5670;
  --text-muted: #8a86a0;
  --accent: #6B5CE7;
  --accent-light: #e8e4f8;
  --accent-dark: #4a3cb8;
  --red: #d94040;
  --green: #3aaa5b;
  --blue: #5b9bd5;
  --shadow: 0 16px 40px rgba(55, 45, 115, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(245, 243, 255, .96), rgba(255, 255, 255, .90)),
    url('/assets/brand/gradient.png') center / cover fixed;
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100%;
}

.boot-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  color: var(--accent);
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.brand-logo {
  width: 170px;
  max-width: 100%;
  height: auto;
  display: block;
}

.login-card {
  width: min(100%, 430px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.90), rgba(255,255,255,.96)),
    url('/assets/brand/coverLakta.jpg') center / cover;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(16px);
}

.login-card h1 {
  margin: 20px 0 8px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 31px;
  font-weight: 600;
  line-height: 1.1;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

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

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(107, 92, 231, .14);
}

.btn {
  min-height: 40px;
  border: 1px solid #111111;
  border-radius: 8px;
  background: #111111;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 600;
  transition: background .18s ease, transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(107, 92, 231, .24);
  transform: translateY(-1px);
}

.btn.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover {
  color: var(--accent-dark);
  border-color: var(--border-hover);
  background: var(--accent-light);
}

.btn.icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 14px;
}

.btn.tiny {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.danger {
  border-color: var(--red);
  background: var(--red);
}

.btn.full {
  width: 100%;
}

.error-box,
.notice-box {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.45;
}

.error-box {
  color: #8b1f1f;
  background: #fdecec;
  border: 1px solid #f4caca;
}

.notice-box {
  color: #275d37;
  background: #edf9f0;
  border: 1px solid #c8eacb;
}

.webmail {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  overflow: hidden;
}

.mail-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 232px minmax(320px, 1fr);
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  background: rgba(255, 255, 255, .72);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow: auto;
}

.compose-trigger {
  min-width: 146px;
  margin: 8px 0 18px 8px;
  min-height: 56px;
  border-radius: 18px;
  justify-content: flex-start;
  padding: 0 22px;
  background: #fff;
  color: #1a1a1a;
  border-color: var(--border);
  box-shadow: 0 3px 10px rgba(55, 45, 115, .13);
}

.compose-trigger:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.compose-plus {
  font-size: 25px;
  line-height: 1;
}

.nav-list {
  display: grid;
  gap: 2px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  min-height: 34px;
  border-radius: 0 18px 18px 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 18px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: rgba(107, 92, 231, .14);
}

.nav-count {
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  min-width: 22px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.main {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 232px minmax(280px, 720px) minmax(max-content, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .90);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.topbar .brand-logo {
  width: 150px;
  max-height: 50px;
  object-fit: contain;
}

body.nour-theme .topbar .brand-logo {
  width: 122px;
  max-height: 54px;
}

.search {
  position: relative;
  min-width: 0;
  z-index: 5;
}

.search input {
  padding-left: 70px;
  padding-right: 92px;
  min-height: 48px;
  border: 0;
  border-radius: 24px;
  background: var(--bg-panel);
  color: var(--text);
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.search .nav-icon,
.search .nav-icon svg {
  width: 22px;
  height: 22px;
}

.search-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.search-button:hover,
.search-button.active {
  background: rgba(255, 255, 255, .72);
  color: var(--accent-dark);
}

.search-button.icon-only {
  right: 48px;
}

.filter-button {
  right: 10px;
}

.search-popover {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  z-index: 20;
}

.search-popover-head,
.search-history-clear,
.search-filter-actions,
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-popover-head {
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-item {
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  text-align: left;
  border-radius: 8px;
}

.history-item:hover {
  background: var(--accent-light);
}

.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.search-filters .field {
  margin-bottom: 0;
}

.search-filters .filter-row,
.search-filter-actions {
  grid-column: 1 / -1;
}

.search-filter-actions {
  justify-content: flex-end;
}

.select.compact {
  min-height: 34px;
  padding: 5px 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.action-short {
  display: none;
}

.top-action-button .nav-icon {
  width: 18px;
  height: 18px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  font-weight: 700;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mail-surface {
  min-height: 0;
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
}

.mail-surface.has-reader {
  grid-template-columns: minmax(480px, 56%) minmax(380px, 44%);
}

.message-list {
  border-right: 1px solid var(--border);
  min-width: 0;
  overflow: auto;
  background: rgba(255, 255, 255, .82);
}

.mail-toolbar {
  min-height: 64px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .75);
  position: sticky;
  top: 0;
  z-index: 2;
}

.mail-toolbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mail-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.select-all-control input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.selection-count {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.list-title {
  margin: 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
}

.mail-table {
  width: 100%;
  display: grid;
}

.mail-row {
  width: 100%;
  min-height: 42px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  padding: 0 16px;
  text-align: left;
  display: grid;
  grid-template-columns: 34px 34px minmax(120px, 220px) minmax(180px, 1fr) 82px 28px 74px;
  align-items: center;
  gap: 8px;
  transition: background .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
}

.mail-row:hover,
.mail-row.active {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--accent), 0 1px 5px rgba(55, 45, 115, .10);
  position: relative;
  z-index: 1;
}

.mail-row.unread .mail-subject,
.mail-row.unread .mail-from,
.mail-row.unread .mail-date {
  color: var(--text);
  font-weight: 600;
}

.mail-check {
  display: grid;
  place-items: center;
}

.mail-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.star-button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  border-radius: 50%;
  padding: 0;
}

.star-button:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.star-button.active {
  color: #f4b400;
}

.mail-from,
.mail-subject,
.mail-preview,
.mail-content {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-from {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.mail-date,
.mail-preview {
  color: var(--text-muted);
  font-size: 12px;
}

.mail-subject {
  font-size: 14px;
  color: var(--text);
}

.mail-row.read .mail-subject,
.mail-row.read .mail-from {
  color: var(--text-secondary);
  font-weight: 400;
}

.mail-separator {
  color: var(--text-muted);
  margin: 0 4px;
}

.mail-attachment {
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.mail-tracking {
  min-width: 0;
}

.tracking-badge,
.tracking-summary {
  border: 1px solid var(--border);
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tracking-summary {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 8px;
}

.mail-attachment .nav-icon {
  width: 16px;
  height: 16px;
}

.mail-attachment svg {
  width: 16px;
  height: 16px;
}

.reader {
  min-width: 0;
  overflow: auto;
  padding: 18px;
  background: rgba(255, 255, 255, .52);
  border-left: 1px solid var(--border);
}

.mail-reader-view {
  height: calc(100vh - 72px);
  min-width: 0;
  overflow: auto;
  background: rgba(255, 255, 255, .62);
}

.full-reader {
  width: min(1180px, 100%);
  margin: 0 auto;
  border-left: 0;
  background: transparent;
}

.mail-surface:not(.has-reader) .reader {
  display: none;
}

.reader-empty,
.settings-pane,
.admin-pane {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 400;
}

.message-card,
.panel {
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.message-card {
  overflow: hidden;
}

.message-head {
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.message-head h2 {
  margin: 0 0 16px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.message-actions .btn {
  min-width: 94px;
  white-space: nowrap;
}

.sender-line {
  display: grid;
  gap: 3px;
}

.sender-line span,
.sender-hint {
  color: var(--text-muted);
  font-size: 12px;
}

.sender-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.sender-panel-below {
  margin: 0 22px 22px;
}

.sender-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sender-menu-wrap {
  position: relative;
}

.sender-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 2px;
}

.sender-menu button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  min-height: 36px;
  padding: 0 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.sender-menu button:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.sender-menu button:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.message-body {
  padding: 22px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.email-frame-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.email-frame {
  width: 100%;
  max-width: 100%;
  min-height: 320px;
  border: 0;
  display: block;
  background: #fff;
}

.attachment-list {
  padding: 0 22px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-preview {
  width: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  display: grid;
}

.attachment-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-panel);
}

.attachment-preview span {
  padding: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.attachment-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
}

.compose-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(520px, calc(100vw - 44px));
  max-height: min(620px, calc(100vh - 44px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(26, 26, 26, .2);
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.compose-panel.expanded {
  width: min(50vw, 820px);
  max-height: calc(100vh - 44px);
}

.compose-head,
.compose-foot {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-panel);
}

.compose-window-actions,
.compose-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-head h3 {
  margin: 0;
  font-size: 15px;
}

.compose-body {
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.compose-attachments {
  display: grid;
  gap: 8px;
}

.compose-attachment-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg-card);
}

.compose-attachment-card img,
.file-preview {
  width: 72px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-panel);
}

.file-preview {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.compose-attachment-meta {
  min-width: 0;
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.compose-attachment-meta strong,
.compose-attachment-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-input {
  max-width: 120px;
  min-height: 30px;
  padding: 5px 8px;
}

.mobile-compose-fab {
  display: none;
}

.compose-address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.editor {
  min-height: 170px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  outline: none;
  line-height: 1.6;
}

.compose-panel.expanded .editor {
  min-height: 360px;
}

.editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(107, 92, 231, .14);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, .32);
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.settings-page {
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(245, 243, 255, .92), rgba(255, 255, 255, .84)),
    url('/assets/brand/gradient.png') center / cover;
}

.settings-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-inline-save {
  margin-top: 16px;
}

.modal {
  width: min(900px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(26, 26, 26, .2);
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 20px;
}

.settings-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.insight-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.insight-card span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.insight-card strong {
  color: var(--text);
  font-size: 24px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-wide {
  grid-column: 1 / -1;
  overflow: auto;
}

.panel {
  padding: 16px;
}

.panel h3 {
  margin: 0 0 14px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--text-secondary);
  font-size: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none !important;
}

body.dark {
  --bg: #151321;
  --bg-card: #211f2f;
  --bg-panel: #29263b;
  --border: #46405f;
  --border-hover: #625a82;
  --text: #f8f6ff;
  --text-secondary: #ddd8ee;
  --text-muted: #aaa3c2;
  background: #151321;
}

body.dark .sidebar,
body.dark .topbar,
body.dark .mail-row,
body.dark .message-card,
body.dark .panel,
body.dark .modal,
body.dark .compose-panel,
body.dark .login-card {
  background: rgba(31, 31, 40, .94);
}

body.dark .input,
body.dark .textarea,
body.dark .select,
body.dark .editor,
body.dark .btn.secondary {
  background: #16161f;
  color: var(--text);
}

.profile-editor {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.profile-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  overflow: hidden;
}

.profile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checkbox-field {
  align-self: end;
  gap: 9px;
}

body.dark .compose-trigger {
  background: #ffffff;
  color: #1a1a1a;
  border-color: #d8d4e8;
}

body.dark .compose-trigger:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

body.dark .message-list,
body.dark .mail-toolbar,
body.dark .reader {
  background: rgba(31, 31, 40, .82);
}

body.nour-theme {
  --text: #1A1A1A;
  --text-secondary: #5f4545;
  --text-muted: #8e6b6b;
  --accent: #F05E5E;
  --accent-light: #FFF0F0;
  --accent-dark: #1A1A1A;
  --bg: #FFF0F0;
  --bg-panel: #FFC2C2;
  --border: #F59595;
  --border-hover: #F05E5E;
}

body.dark.nour-theme {
  --bg: #1A1A1A;
  --bg-card: #242020;
  --bg-panel: #3a2424;
  --text: #FFF0F0;
  --text-secondary: #FFC2C2;
  --text-muted: #F59595;
  --accent-light: #3a2424;
  --accent-dark: #FFC2C2;
  --border: #F05E5E;
  --border-hover: #F59595;
}

body.dark.nour-theme .btn.secondary {
  border-color: #F59595;
  color: #FFF0F0;
}

body.dark.nour-theme .btn.secondary:hover {
  background: #3a2424;
  color: #FFC2C2;
}

@media (max-width: 980px) {
  .mail-layout {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: 78px minmax(180px, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar .brand-logo {
    width: 46px;
    content: url('/assets/brand/icon.png');
  }

  body.nour-theme .topbar .brand-logo {
    width: 54px;
    max-height: 46px;
    content: url('/assets/brand/logonour.png');
  }

  .sidebar {
    padding: 14px 8px;
  }

  .nav-label,
  .nav-count,
  .compose-trigger span {
    display: none;
  }

  .compose-trigger {
    width: 46px;
    min-width: 46px;
    margin: 0 auto 14px;
    padding: 0;
    justify-content: center;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0;
  }

  .mail-surface,
  .mail-surface.has-reader {
    grid-template-columns: 1fr;
  }

  .mail-row {
    grid-template-columns: 30px 30px minmax(96px, 168px) minmax(120px, 1fr) 74px 24px 64px;
    padding: 0 10px;
  }

  .mail-surface .reader {
    display: none;
  }

  .mail-surface .reader.mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: var(--bg);
  }

  .compose-panel.expanded {
    width: calc(100vw - 44px);
  }
}

@media (max-width: 680px) {
  .webmail {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .mail-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 8;
    border-right: 0;
    border-top: 1px solid var(--border);
    padding: 8px;
  }

  .compose-trigger {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-item:nth-child(n+6) {
    display: none;
  }

  .main {
    padding-bottom: 66px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
    gap: 8px;
  }

  .topbar .brand-lockup {
    display: none;
  }

  .search input {
    min-height: 42px;
    padding-left: 52px;
    padding-right: 86px;
  }

  .search-icon {
    left: 20px;
  }

  .search-filters {
    grid-template-columns: 1fr;
  }

  .filter-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .top-actions {
    justify-content: flex-end;
    gap: 6px;
  }

  .top-action-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
  }

  .action-label {
    display: none;
  }

  .mail-surface,
  .mail-reader-view,
  .settings-page {
    height: calc(100vh - 136px);
  }

  .mail-row {
    grid-template-columns: 28px 28px minmax(0, 1fr) 58px;
    min-height: 58px;
    gap: 6px;
  }

  .mail-from {
    grid-column: 3 / 4;
    align-self: end;
  }

  .mail-content {
    grid-column: 3 / 5;
    align-self: start;
  }

  .mail-attachment {
    display: none;
  }

  .mail-tracking {
    display: none;
  }

  .mail-date {
    grid-column: 4 / 5;
    grid-row: 1;
    align-self: end;
    text-align: right;
  }

  .settings-grid,
  .admin-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .mail-toolbar {
    align-items: flex-start;
  }

  .profile-editor {
    grid-template-columns: 1fr;
  }

  .compose-panel,
  .compose-panel.expanded {
    inset: 8px;
    bottom: 8px;
    width: auto;
    max-height: none;
    z-index: 32;
  }

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

  .compose-address-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .mobile-compose-fab {
    position: fixed;
    right: 16px;
    bottom: 82px;
    z-index: 18;
    width: 56px;
    height: 56px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 30px;
    line-height: 0;
    padding: 0 0 4px;
    box-shadow: 0 10px 24px rgba(26, 26, 26, .22);
    display: grid;
    place-items: center;
  }
}
