* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #1a1d21;
  font-size: 14px;
}

.hidden { display: none !important; }
.error { color: #b42318; font-size: 13px; margin: 8px 0; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 16px; color: #5c6470; font-size: 13px; }

.login-card label { font-size: 13px; color: #5c6470; margin-top: 8px; }

.login-card input {
  padding: 9px 10px;
  border: 1px solid #d3d8de;
  border-radius: 6px;
  font-size: 14px;
}

.login-card button {
  margin-top: 18px;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: #2f6fed;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.login-card button:disabled { background: #9db8f5; cursor: default; }

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: 250px 380px 1fr;
  height: 100vh;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid #e3e6ea;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow-y: auto;
}

.mailbox-switcher { display: flex; align-items: center; gap: 8px; }
.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #5c6470;
  margin-top: 10px;
  cursor: pointer;
}
.remember-label input[type="checkbox"] {
  margin: 0;
  width: auto;
  cursor: pointer;
}

.icon-button-small {
  background: transparent;
  border: 1px solid #d3d8de;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: #2f6fed;
}
.icon-button-small:hover {
  background: #f0f4ff;
  border-color: #2f6fed;
}

.mailbox-quick-switch {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mailbox-tab-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: 5px;
  text-decoration: none;
  font-size: 12px;
  color: #4b5563;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.mailbox-tab-link:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.mailbox-tab-link.active {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 600;
  border-color: #c7d2fe;
}

.switcher-label { font-size: 12px; color: #5c6470; }
.mailbox-switcher select { flex: 1; padding: 6px; border: 1px solid #d3d8de; border-radius: 6px; }

.badge {
  background: #2f6fed;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 7px;
}

.compose-button {
  padding: 9px;
  border: 0;
  border-radius: 6px;
  background: #2f6fed;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.folder-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.folder-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}

.folder-item:hover { background: #f0f2f5; }
.folder-item.active { background: #e8effd; color: #1d4fd7; font-weight: 600; }

.sidebar-footer { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid #e3e6ea; padding-top: 8px; }

.link-button {
  border: 0;
  background: none;
  color: #5c6470;
  font-size: 13px;
  text-align: left;
  padding: 5px 4px;
  cursor: pointer;
  border-radius: 4px;
}

.link-button:hover { background: #f0f2f5; }

/* ---------- list ---------- */

.list-pane { display: flex; flex-direction: column; border-right: 1px solid #e3e6ea; background: #fff; }

.list-toolbar { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid #e3e6ea; }

.list-toolbar input {
  flex: 1;
  padding: 7px 9px;
  border: 1px solid #d3d8de;
  border-radius: 6px;
  font-size: 13px;
}

.list-toolbar select { padding: 7px; border: 1px solid #d3d8de; border-radius: 6px; font-size: 13px; }
.list-toolbar button { padding: 7px 12px; border: 0; border-radius: 6px; background: #eef1f5; cursor: pointer; font-size: 13px; }

.message-list { flex: 1; overflow-y: auto; }

.message-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f3;
  cursor: pointer;
  align-items: flex-start;
}

.message-row:hover { background: #f7f9fc; }
.message-row.selected { background: #e8effd; }
.message-row.unread .row-from, .message-row.unread .row-subject { font-weight: 700; }

.row-star { border: 0; background: none; cursor: pointer; color: #c3c9d2; font-size: 15px; padding: 0; }
.row-star.starred { color: #f5a623; }

.row-main { flex: 1; min-width: 0; }
.row-from { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subject { font-size: 13px; color: #2a2f36; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 11px; color: #8a919c; display: flex; gap: 8px; margin-top: 2px; }

.list-status { padding: 24px; text-align: center; color: #8a919c; }

.pagination { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid #e3e6ea; align-items: center; }
.pagination button { border: 1px solid #d3d8de; background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.pagination span { font-size: 12px; color: #5c6470; }

/* ---------- read ---------- */

.read-pane { overflow-y: auto; background: #fff; }
.read-empty { padding: 40px; text-align: center; color: #8a919c; }

.read-head { padding: 16px 20px 12px; border-bottom: 1px solid #eef0f3; }
.read-subject { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.read-line { font-size: 13px; color: #2a2f36; margin: 2px 0; }
.read-line b { color: #5c6470; font-weight: 600; display: inline-block; min-width: 70px; }
.read-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

.read-actions button, .read-actions select {
  border: 1px solid #d3d8de;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.read-body { padding: 16px 20px 40px; font-size: 14px; line-height: 1.55; word-wrap: break-word; }
.read-body pre { white-space: pre-wrap; font-family: inherit; margin: 0; }
.read-body img { max-width: 100%; }

.read-images-toggle { margin: 8px 0; }
.read-images-toggle button { border: 1px solid #d3d8de; background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }

.attachments { border-top: 1px solid #eef0f3; padding: 12px 20px; }
.attachments h4 { margin: 0 0 8px; font-size: 13px; color: #5c6470; }
.attachment-item { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-size: 13px; }
.attachment-item a { color: #2f6fed; text-decoration: none; }
.attachment-size { color: #8a919c; font-size: 12px; }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: 92vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eef0f3; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid #eef0f3; align-items: center; }

.icon-button { border: 0; background: none; font-size: 20px; cursor: pointer; color: #5c6470; line-height: 1; }

.compose-modal .compose-fields { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px 4px; }
.compose-fields input { padding: 8px 10px; border: 1px solid #d3d8de; border-radius: 6px; font-size: 13px; }

.compose-body {
  margin: 10px 18px;
  min-height: 220px;
  border: 1px solid #d3d8de;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.compose-attachments { padding: 0 18px; }
.files-list { font-size: 12px; color: #5c6470; margin: 6px 0; }
.compose-status { font-size: 12px; color: #8a919c; flex: 1; }

.primary-button { border: 0; background: #2f6fed; color: #fff; border-radius: 6px; padding: 8px 16px; font-size: 13px; cursor: pointer; }
.secondary-button { border: 1px solid #d3d8de; background: #fff; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; }

.mailbox-modal .mailbox-manage-list { padding: 12px 18px; border-bottom: 1px solid #eef0f3; }
.mailbox-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.mailbox-row .address { flex: 1; }
.mailbox-row .active-tag { color: #1d7a3d; font-size: 12px; }
.mailbox-row button { border: 1px solid #d3d8de; background: #fff; border-radius: 6px; padding: 3px 9px; font-size: 12px; cursor: pointer; }

.mailbox-add { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.mailbox-add h3 { margin: 0; font-size: 14px; }
.mailbox-add input { padding: 8px 10px; border: 1px solid #d3d8de; border-radius: 6px; font-size: 13px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1d21;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 40;
  max-width: 80%;
}

.mobile-only { display: none; }

.burger {
  border: 1px solid #d3d8de;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
}

/* ---------- mobile ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; position: relative; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 25;
    width: 250px;
    transform: translateX(-100%);
    transition: transform 0.15s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .list-pane { border-right: 0; }
  .read-pane {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: #fff;
  }
  body.message-open .read-pane {
    display: block;
  }
  .mobile-only { display: inline-block; }
}
