body {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 760;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #17191c;
  color: #fff;
  font-size: 15px;
}

.topbar-primary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-tool-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.topbar-tool-link:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-label {
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-shell {
  min-height: calc(100vh - 62px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(400px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-panel > p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .button {
  margin-top: 4px;
}

.mailbox-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.mailbox-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.mailbox-heading h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
}

.mailbox-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.account-switcher,
.alias-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 9px;
  scrollbar-width: thin;
}

.account-switcher button,
.alias-switcher button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: #475467;
  font-weight: 650;
}

.alias-switcher button {
  min-height: 30px;
  border-radius: 999px;
  background: var(--surface-subtle);
  font-size: 12px;
}

.account-switcher button.active,
.alias-switcher button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #0d55bd;
}

.mail-list-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.mail-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mail-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 0.34fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 68px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms ease;
}

.mail-item:last-child {
  border-bottom: 0;
}

.mail-item:hover {
  background: var(--surface-subtle);
}

.mail-item.unread::before {
  content: '';
  position: absolute;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.mail-from {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-subject {
  min-width: 0;
}

.mail-subject strong,
.mail-subject span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-subject strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.mail-subject span {
  color: var(--muted);
  font-size: 12px;
}

.mail-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.mail-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
}

.mail-pagination-actions {
  display: flex;
  gap: 8px;
}

.mail-dialog {
  width: min(860px, calc(100vw - 32px));
}

.mail-dialog .dialog-body {
  min-height: 280px;
  padding: 0;
}

.mail-dialog iframe {
  width: 100%;
  min-height: 56vh;
  border: 0;
  background: #fff;
}

.mail-dialog pre {
  margin: 0;
  padding: 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  line-height: 1.7;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar-primary {
    gap: 6px;
  }

  .brand-label,
  .tool-link-suffix {
    display: none;
  }

  .session-label,
  .topbar .api-link {
    display: none;
  }

  .mailbox-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .mailbox-heading {
    align-items: flex-start;
  }

  .mail-item {
    grid-template-columns: 1fr auto;
    gap: 5px 12px;
    padding: 13px 14px;
  }

  .mail-from {
    grid-column: 1;
  }

  .mail-date {
    grid-column: 2;
    grid-row: 1;
  }

  .mail-subject {
    grid-column: 1 / -1;
  }

  .mail-pagination {
    align-items: flex-start;
    flex-direction: column;
  }
}
