:root {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  color: #202124;
  background: #f7f8fa;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f7f8fa;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================
   TOPBAR
========================= */

.topbar {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid #e6e8eb;

  display: flex;
  align-items: center;

  padding: 0 18px;
  gap: 20px;

  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;

  min-width: 190px;
}

.outlook-logo {
  display: flex;
  align-items: center;
  gap: 9px;

  font-size: 20px;
  font-weight: 650;
  color: #202124;
}

.outlook-logo-box {
  width: 34px;
  height: 34px;

  border-radius: 8px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #087cfa;
  color: white;

  font-weight: 700;
}

.search-box {
  flex: 1;
  max-width: 700px;
  height: 42px;

  display: flex;
  align-items: center;
  gap: 10px;

  padding: 0 14px;

  border-radius: 9px;

  background: #f2f4f7;
  color: #70757a;
}

.search-box input {
  flex: 1;

  border: none;
  outline: none;
  background: transparent;

  font-size: 14px;
}

.topbar-actions {
  margin-left: auto;

  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-button {
  width: 38px;
  height: 38px;

  border-radius: 8px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #555b65;
}

.icon-button:hover {
  background: #f0f2f5;
}

.avatar {
  width: 34px;
  height: 34px;

  border-radius: 50%;

  background: #8664d9;
  color: white;

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 600;
}

.avatar.large {
  width: 42px;
  height: 42px;
}

.mobile-menu {
  display: none;
}

/* =========================
   BODY
========================= */

.app-body {
  flex: 1;

  display: flex;

  min-height: calc(100vh - 64px);
}

/* =========================
   SIDEBAR
========================= */

.sidebar {
  width: 240px;

  background: #ffffff;
  border-right: 1px solid #e6e8eb;

  padding: 18px 12px;

  display: flex;
  flex-direction: column;
}

.sidebar-mobile-header {
  display: none;
}

.compose-button {
  width: 100%;
  height: 46px;

  border-radius: 8px;

  background: #087cfa;
  color: white;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  font-weight: 600;

  margin-bottom: 18px;
}

.compose-button:hover {
  background: #066de0;
}

.folder-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.folder-item {
  width: 100%;
  height: 42px;

  display: flex;
  align-items: center;
  gap: 12px;

  padding: 0 12px;

  border-radius: 7px;

  color: #50555d;

  text-align: left;
}

.folder-item:hover {
  background: #f1f3f5;
}

.folder-item.active {
  background: #e8f2ff;
  color: #087cfa;
  font-weight: 600;
}

.folder-count {
  margin-left: auto;
  font-size: 12px;
}

.sidebar-bottom {
  margin-top: auto;
}

.account-card {
  padding: 12px;

  display: flex;
  align-items: center;
  gap: 10px;

  border-top: 1px solid #eceef0;
}

.account-card div:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.account-card strong {
  font-size: 13px;
}

.account-card span {
  font-size: 11px;
  color: #747a83;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   MAIN
========================= */

.main {
  flex: 1;

  min-width: 0;

  display: flex;
  flex-direction: column;

  background: #f7f8fa;
}

.toolbar {
  height: 58px;

  display: flex;
  align-items: center;

  padding: 0 18px;

  background: white;
  border-bottom: 1px solid #e6e8eb;

  gap: 4px;
}

.toolbar-title {
  font-size: 18px;
  font-weight: 650;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-button {
  height: 36px;

  padding: 0 10px;

  display: flex;
  align-items: center;
  gap: 7px;

  border-radius: 7px;

  color: #555b65;
}

.toolbar-button:hover {
  background: #f0f2f5;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: #e0e3e7;

  margin: 0 7px;
}

/* =========================
   CONTENT
========================= */

.content {
  flex: 1;

  display: grid;
  grid-template-columns: minmax(330px, 430px) 1fr;

  min-height: 0;
}

/* =========================
   EMAIL LIST
========================= */

.email-list {
  background: #ffffff;

  border-right: 1px solid #e2e5e8;

  overflow-y: auto;
}

.email-row {
  min-height: 92px;

  padding: 12px 13px;

  display: flex;
  align-items: flex-start;
  gap: 9px;

  border-bottom: 1px solid #edf0f2;

  cursor: pointer;

  transition: background 0.15s;
}

.email-row:hover {
  background: #f7f9fb;
}

.email-row.selected {
  background: #eef6ff;
}

.email-row.unread {
  background: #fbfdff;
}

.email-row.unread .sender-name,
.email-row.unread .email-subject {
  font-weight: 700;
}

.email-checkbox {
  padding-top: 5px;
}

.email-checkbox input {
  width: 15px;
  height: 15px;
}

.star-button,
.flag-button {
  width: 27px;
  height: 27px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #9aa0a6;

  border-radius: 6px;

  flex-shrink: 0;
}

.star-button:hover,
.flag-button:hover {
  background: #edf0f2;
}

.star-button.starred {
  color: #f2b01e;
}

.flag-button.flagged {
  color: #e55353;
}

.sender-avatar {
  width: 36px;
  height: 36px;

  flex-shrink: 0;

  border-radius: 50%;

  background: #e3e8f0;

  color: #4c5665;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 13px;
  font-weight: 700;
}

.email-main {
  flex: 1;

  min-width: 0;
}

.email-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sender-name {
  font-size: 13px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-date {
  margin-left: auto;

  font-size: 11px;
  color: #7c828a;

  white-space: nowrap;
}

.email-subject {
  margin-top: 5px;

  display: flex;
  align-items: center;
  gap: 6px;

  font-size: 13px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-preview {
  margin-top: 4px;

  color: #747a82;

  font-size: 12px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  min-height: 400px;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  color: #8a9097;

  text-align: center;
}

.empty-state h3 {
  margin: 15px 0 5px;

  color: #50555c;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

/* =========================
   EMAIL DETAIL
========================= */

.email-detail {
  background: white;

  min-width: 0;

  overflow-y: auto;

  padding: 30px 38px;
}

.empty-detail {
  display: flex;

  flex-direction: column;

  align-items: center;
  justify-content: center;

  color: #9aa0a6;

  text-align: center;
}

.empty-detail h2 {
  color: #555b65;
  margin-bottom: 5px;
}

.empty-detail p {
  margin-top: 0;
  font-size: 13px;
}

.message-header {
  display: flex;
  align-items: flex-start;

  gap: 15px;

  padding-bottom: 25px;

  border-bottom: 1px solid #edf0f2;
}

.message-avatar {
  width: 46px;
  height: 46px;

  border-radius: 50%;

  background: #e1e8f4;

  color: #4d5c70;

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 700;
}

.message-info {
  flex: 1;
  min-width: 0;
}

.message-info h1 {
  font-size: 22px;

  margin: 0 0 12px;

  font-weight: 650;

  color: #202124;
}

.message-sender {
  display: flex;
  align-items: center;

  gap: 8px;

  font-size: 13px;
}

.message-sender span {
  color: #747a82;
}

.message-to {
  margin-top: 7px;

  color: #7c828a;

  font-size: 12px;
}

.message-actions {
  display: flex;
  gap: 3px;
}

.active-icon {
  color: #087cfa;
}

.message-body {
  padding: 30px 10px;

  max-width: 820px;

  font-size: 15px;

  line-height: 1.75;

  color: #30343a;
}

.attachments {
  max-width: 820px;

  padding: 0 10px;
}

.attachments h3 {
  font-size: 13px;
  margin-bottom: 12px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment {
  min-width: 240px;

  border: 1px solid #e2e5e8;

  border-radius: 8px;

  padding: 12px;

  display: flex;
  align-items: center;
  gap: 10px;
}

.attachment > div {
  flex: 1;

  min-width: 0;

  display: flex;
  flex-direction: column;
}

.attachment strong {
  font-size: 12px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment span {
  font-size: 11px;
  color: #80868d;
}

.attachment-download {
  font-size: 11px;

  color: #087cfa;
}

.reply-area {
  max-width: 820px;

  padding: 30px 10px;

  display: flex;
  gap: 8px;
}

.reply-button {
  height: 40px;

  padding: 0 15px;

  border-radius: 7px;

  display: flex;
  align-items: center;
  gap: 7px;

  background: #087cfa;

  color: white;

  font-weight: 600;
}

.reply-button.secondary {
  background: #eef1f4;

  color: #454b53;
}

.mobile-detail-header {
  display: none;
}

/* =========================
   COMPOSE
========================= */

.modal-overlay {
  position: fixed;

  inset: 0;

  background: rgba(0, 0, 0, 0.25);

  z-index: 100;

  display: flex;

  align-items: flex-end;
  justify-content: flex-end;

  padding: 24px;
}

.compose-modal {
  width: min(620px, 100%);

  height: min(620px, 80vh);

  background: white;

  border-radius: 10px;

  box-shadow:
    0 15px 50px rgba(0, 0, 0, 0.18),
    0 2px 10px rgba(0, 0, 0, 0.08);

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

.compose-header {
  height: 50px;

  padding: 0 15px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background: #f4f5f7;
}

.compose-fields {
  flex: 1;

  display: flex;
  flex-direction: column;
}

.compose-field {
  min-height: 45px;

  padding: 0 15px;

  border-bottom: 1px solid #e8eaed;

  display: flex;
  align-items: center;
  gap: 12px;
}

.compose-field label {
  width: 60px;

  font-size: 12px;
  color: #777d85;
}

.compose-field input {
  flex: 1;

  height: 42px;

  border: 0;

  outline: 0;

  font-size: 13px;
}

.compose-fields textarea {
  flex: 1;

  border: 0;

  outline: 0;

  resize: none;

  padding: 18px 15px;

  font-size: 14px;

  line-height: 1.6;
}

.compose-toolbar {
  height: 60px;

  padding: 0 12px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-top: 1px solid #e8eaed;
}

.compose-tools {
  display: flex;
}

.send-button {
  height: 38px;

  padding: 0 17px;

  border-radius: 7px;

  background: #087cfa;

  color: white;

  display: flex;
  align-items: center;
  gap: 8px;

  font-weight: 600;
}

/* =========================
   MOBILE NAV
========================= */

.mobile-bottom-nav {
  display: none;
}

/* =========================
   SIDEBAR OVERLAY
========================= */

.sidebar-overlay {
  display: none;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1000px) {
  .sidebar {
    width: 210px;
  }

  .content {
    grid-template-columns: minmax(300px, 380px) 1fr;
  }

  .email-detail {
    padding: 25px;
  }
}

@media (max-width: 760px) {
  body {
    background: white;
  }

  .topbar {
    height: 58px;

    padding: 0 10px;

    gap: 8px;
  }

  .mobile-menu {
    display: flex;
  }

  .topbar-left {
    min-width: auto;
  }

  .outlook-logo span {
    display: none;
  }

  .outlook-logo-box {
    width: 32px;
    height: 32px;
  }

  .search-box {
    height: 38px;
    padding: 0 10px;
  }

  .topbar-actions {
    display: none;
  }

  .app-body {
    min-height: calc(100vh - 58px);
  }

  .sidebar {
    position: fixed;

    top: 0;
    bottom: 0;
    left: 0;

    width: 290px;

    z-index: 200;

    transform: translateX(-100%);

    transition: transform 0.2s ease;

    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.12);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-mobile-header {
    height: 44px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 10px;
  }

  .sidebar-overlay {
    display: block;

    position: fixed;

    inset: 0;

    z-index: 150;

    background: rgba(0, 0, 0, 0.28);
  }

  .main {
    width: 100%;
  }

  .toolbar {
    height: 50px;

    padding: 0 10px;
  }

  .toolbar-button span {
    display: none;
  }

  .content {
    display: block;

    position: relative;

    height: calc(100vh - 108px);
  }

  .email-list {
    height: 100%;

    border-right: none;
  }

  .email-list.mobile-hidden {
    display: none;
  }

  .email-detail {
    display: none;

    position: absolute;

    inset: 0;

    padding: 0;

    height: 100%;

    z-index: 20;
  }

  .email-detail.mobile-visible {
    display: block;
  }

  .empty-detail {
    display: none;
  }

  .mobile-detail-header {
    height: 54px;

    padding: 0 8px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #e6e8eb;
  }

  .message-header {
    padding: 18px 15px;

    gap: 12px;
  }

  .message-info h1 {
    font-size: 18px;

    line-height: 1.35;
  }

  .message-sender {
    flex-wrap: wrap;
  }

  .message-actions {
    display: none;
  }

  .message-body {
    padding: 22px 18px;

    font-size: 14px;
  }

  .attachments {
    padding: 0 18px;
  }

  .attachment {
    min-width: 0;

    width: 100%;
  }

  .reply-area {
    padding: 20px 18px 100px;
  }

  .mobile-bottom-nav {
    position: fixed;

    left: 0;
    right: 0;
    bottom: 0;

    height: 62px;

    background: white;

    border-top: 1px solid #e2e5e8;

    z-index: 100;

    display: grid;

    grid-template-columns: repeat(5, 1fr);
  }

  .mobile-bottom-nav button {
    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 3px;

    color: #727881;

    font-size: 10px;
  }

  .mobile-bottom-nav button.active {
    color: #087cfa;
  }

  .email-row {
    min-height: 82px;

    padding: 10px;
  }

  .sender-avatar {
    width: 34px;
    height: 34px;
  }

  .email-checkbox {
    display: none;
  }

  .star-button,
  .flag-button {
    width: 25px;
  }

  .modal-overlay {
    padding: 0;

    align-items: stretch;
  }

  .compose-modal {
    width: 100%;
    height: 100%;

    border-radius: 0;
  }

  .compose-header {
    height: 58px;
  }
}

@media (max-width: 450px) {
  .topbar {
    padding: 0 7px;
  }

  .search-box {
    flex: 1;
  }

  .email-row {
    gap: 6px;
  }

  .email-date {
    font-size: 10px;
  }

  .email-subject {
    font-size: 12px;
  }

  .email-preview {
    font-size: 11px;
  }

  .message-avatar {
    width: 40px;
    height: 40px;
  }
}