:root {
  --bg-main: #f6f8fc;
  --bg-surface: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e0ebff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Текст, який має сенс копіювати: поля вводу, листи, адреси */
input,
textarea,
.email-sender,
.email-subject,
.email-snippet,
#detail-subject,
.sender-line,
.recipient-line,
#detail-date,
#current-user-email,
.domain-suffix,
#safe-link-url-box,
.admin-users-table td,
.auth-error {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

button,
.attachment-chip,
.attach-btn,
.admin-users-table button {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hidden {
  display: none !important;
}

/* ========================
   ЕКРАН АВТОРИЗАЦІЇ
   ======================== */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #dbeafe, #f8fafc 60%);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-surface);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.auth-logo-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-select {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.lang-select.compact {
  padding: 6px 8px;
}

.lang-select.full-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  background: #ffffff;
}

.logo-img {
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.auth-logo-img {
  height: 56px;
  width: auto;
}

.brand-logo-img {
  height: 36px;
  width: auto;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.email-input-group {
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
}

.email-input-group input {
  border: none;
  border-radius: 0;
}

.email-input-group input:focus {
  box-shadow: none;
}

.domain-suffix {
  background: #f1f5f9;
  color: #475569;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  border-left: 1px solid #cbd5e1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.full-width {
  width: 100%;
}

/* ========================
   ОСНОВНИЙ ІНТЕРФЕЙС ПОШТИ
   ======================== */
.mail-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  min-height: 64px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn.mobile-menu-btn {
  display: none;
  font-size: 20px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 140;
}

@media (min-width: 769px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.contact-dev-btn {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: #334155;
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.contact-dev-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--primary);
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
}

.topbar-search {
  flex: 1;
  max-width: 580px;
  background: #eaf1fb;
  border-radius: 24px;
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}

.topbar-search:focus-within {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.topbar-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-Menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.topbar-lang-select {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.topbar-lang-select:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.user-email-pill {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.user-email-pill:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.logout-btn {
  width: auto !important;
  border-radius: 18px !important;
  padding: 0 12px;
  font-size: 13px !important;
  font-weight: 600;
  color: #475569;
  border: 1px solid var(--border-color) !important;
  background: #ffffff !important;
}

.logout-btn:hover {
  background: #f1f5f9 !important;
  color: var(--danger);
}

.btn-outline-danger {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
}

.btn-outline-danger:hover {
  background: #fee2e2;
}

.btn-outline-primary {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline-primary:hover {
  background: #dbeafe;
}

.action-btn.primary-action {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.action-btn.primary-action:hover {
  background: #dbeafe;
}

/* ========================
   АДМІН-ПАНЕЛЬ
   ======================== */
.admin-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #ffffff;
}

.admin-content {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.admin-stat-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
}

.admin-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.admin-stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.admin-pools-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
  background: #ffffff;
}

.admin-pools-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.admin-pools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 18px;
}

.pool-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pool-input-row input {
  width: 140px;
}

.pool-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.pool-hint.warning {
  color: #b45309;
}

.admin-pools-card .btn-primary {
  margin-top: 4px;
}

.admin-table-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow-x: auto;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.admin-users-table th,
.admin-users-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  white-space: nowrap;
}

.admin-users-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
}

.admin-actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.active {
  background: #dcfce7;
  color: #166534;
}

.status-pill.blocked {
  background: #fee2e2;
  color: #991b1b;
}

.small-modal {
  max-width: 440px !important;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 4px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.avatar.large {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.icon-btn {
  border: none;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(15, 23, 42, 0.08);
}

/* ========================
   ОСНОВНА СТРУКТУРА (SIDEBAR + CONTENT)
   ======================== */
.main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 256px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-main);
}

.compose-btn {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.15s;
}

.compose-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  background: #f1f5f9;
}

.compose-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.folder-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-item {
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 0 20px 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.folder-item:hover {
  background: #eaeef6;
}

.folder-item.active {
  background: #d3e3fd;
  color: #041e49;
  font-weight: 700;
}

.folder-label {
  flex: 1;
}

.folder-badge {
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.folder-badge.muted {
  background: #cbd5e1;
  color: #1e293b;
}

.storage-widget {
  margin-top: auto;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.storage-bar-bg {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.storage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.25s ease, background 0.25s ease;
}

.storage-bar-fill.warning {
  background: #f59e0b;
}

.storage-bar-fill.danger {
  background: var(--danger);
}

.storage-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.storage-delete-all-btn {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.storage-delete-all-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.storage-delete-keep-starred-btn {
  margin-top: 8px;
}

.confirm-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-primary);
}

.active-sessions-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.safe-link-url-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 13px;
  color: #0f172a;
  word-break: break-all;
}

.btn-danger-solid {
  background: var(--danger);
  color: #ffffff;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger-solid:hover {
  background: #b91c1c;
}

/* ========================
   СПИСОК ЛИСТІВ
   ======================== */
.content-area {
  flex: 1;
  background: var(--bg-surface);
  margin: 0 16px 16px 0;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-left h2 {
  font-size: 16px;
  font-weight: 700;
}

.muted-text {
  color: var(--text-secondary);
  font-size: 13px;
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
}

.email-row:hover {
  background: #f8fafc;
  box-shadow: inset 1px 0 0 #cbd5e1, inset -1px 0 0 #cbd5e1, 0 1px 2px rgba(0, 0, 0, 0.05);
}

.email-row.unread {
  background: #ffffff;
  font-weight: 700;
}

.email-row.read {
  background: #f8fafc;
  color: #475569;
}

.email-row.selected {
  background: #dbeafe !important;
}

.email-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.star-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
}

.star-btn.starred {
  color: #f59e0b;
}

.email-sender {
  width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.email-content-preview {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-subject {
  color: #0f172a;
}

.email-snippet {
  color: var(--text-secondary);
  font-weight: 400;
}

.email-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: 8px;
}

.empty-state {
  padding: 70px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ========================
   ПЕРЕГЛЯД ЛИСТА
   ======================== */
.email-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.detail-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.btn-back {
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-back:hover {
  background: #f1f5f9;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.action-btn:hover {
  background: #f1f5f9;
}

.action-btn.danger:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.detail-header {
  padding: 24px 28px 16px 28px;
  border-bottom: 1px solid #f1f5f9;
}

.detail-subject-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-subject-row h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}

.folder-tag {
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-sender-info {
  flex: 1;
}

.sender-line {
  font-size: 14px;
  margin-bottom: 2px;
}

.sender-address {
  color: var(--text-secondary);
  font-size: 13px;
  margin-left: 6px;
}

.recipient-line {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.detail-date {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.detail-attachments {
  padding: 12px 28px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.images-privacy-banner {
  padding: 10px 28px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-show-images {
  border: 1px solid #f59e0b;
  background: #ffffff;
  color: #b45309;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-show-images:hover {
  background: #fef3c7;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.attachment-chip:hover {
  background: #eff6ff;
  border-color: var(--primary);
}

.detail-body {
  padding: 20px 28px;
  font-size: 15px;
  line-height: 1.65;
  color: #1e293b;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.email-sandbox-frame {
  width: 100%;
  flex: 1;
  min-height: 320px;
  border: none;
  background: transparent;
}

.detail-footer {
  padding: 16px 28px 28px 28px;
  display: flex;
  gap: 10px;
}

.btn-reply {
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 9px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.btn-reply:hover {
  background: #f1f5f9;
}

/* ========================
   СТОРІНКА НАПИСАННЯ ЛИСТА
   ======================== */
.compose-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
}

.compose-page-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.compose-page-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compose-page-fields {
  padding: 8px 28px 0 28px;
}

.compose-field {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.compose-field label {
  width: 70px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.compose-field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  background: transparent;
}

.compose-field input:disabled {
  color: var(--text-secondary);
}

.compose-page-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  padding: 20px 28px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  line-height: 1.65;
  color: var(--text-primary);
}

.compose-attachments {
  padding: 8px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compose-att-item {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
}

.compose-page-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compose-footer-left,
.compose-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.attach-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.attach-btn:hover {
  background: #f1f5f9;
}

/* ========================
   МОДАЛЬНЕ ВІКНО НАЛАШТУВАНЬ
   ======================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 18px;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========================
   TOAST СПОВІЩЕННЯ
   ======================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================
   МОБІЛЬНА АДАПТАЦІЯ (ТЕЛЕФОНИ ТА ПЛАНШЕТИ)
   ======================== */
@media (max-width: 768px) {
  .auth-card {
    padding: 22px 18px;
    border-radius: 14px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .icon-btn.mobile-menu-btn {
    display: flex;
  }

  .brand {
    min-width: auto;
    gap: 6px;
  }

  .brand-name {
    font-size: 18px;
  }

  .topbar-actions {
    margin-left: auto;
    gap: 6px;
  }

  .user-Menu {
    gap: 6px;
    margin-left: 0;
  }

  .user-email-pill {
    max-width: 135px;
    padding: 5px 9px;
    font-size: 12px;
  }

  #current-user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-lang-select {
    padding: 5px 8px;
    font-size: 12px;
  }

  .logout-btn {
    padding: 0 9px !important;
    font-size: 12px !important;
    height: 30px;
  }

  .topbar-search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
    height: 38px;
    padding: 0 12px;
  }

  .main-container {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    z-index: 150;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    padding: 18px 12px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .compose-btn {
    width: 100%;
    justify-content: center;
  }

  .content-area {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .toolbar {
    padding: 0 10px;
    height: 46px;
  }

  .toolbar-left h2 {
    font-size: 15px;
  }

  /* Адаптивний список листів у 2 рядки для мобільних екранів */
  .email-row {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }

  .email-sender {
    width: auto;
    flex: 1;
    font-size: 14px;
  }

  .email-date {
    margin-left: auto;
    font-size: 11.5px;
  }

  .email-content-preview {
    flex: 1 1 100%;
    padding-left: 52px;
    font-size: 13px;
    margin-top: -2px;
  }

  /* Деталі відкритого листа */
  .detail-toolbar {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .detail-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .action-btn,
  .btn-back {
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .detail-header {
    padding: 16px 14px 12px 14px;
  }

  .detail-subject-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }

  .detail-subject-row h1 {
    font-size: 18px;
  }

  .detail-attachments {
    padding: 10px 14px;
  }

  .detail-body {
    padding: 14px;
  }

  .detail-footer {
    padding: 12px 14px 20px 14px;
  }

  /* Сторінка написання листа на телефоні */
  .compose-page-fields {
    padding: 4px 14px 0 14px;
  }

  .compose-field {
    padding: 10px 0;
  }

  .compose-field label {
    width: 55px;
    font-size: 13px;
  }

  .compose-field input {
    font-size: 16px; /* 16px запобігає авто-зуму в iOS Safari */
  }

  .compose-page-textarea {
    padding: 14px;
    font-size: 16px;
  }

  .compose-attachments {
    padding: 6px 14px;
  }

  .compose-page-footer {
    padding: 12px 14px;
  }

  .compose-footer-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .compose-footer-left .btn-primary,
  .compose-footer-left .attach-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    padding: 11px 12px;
    font-size: 13.5px;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    width: 100%;
    text-align: center;
  }
}
