.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.reader-toolbar .button.is-small {
  margin-right: 4px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: var(--line-strong);
}

.star-toggle.is-starred {
  color: var(--star);
}

.reader-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 32px 40px;
}

.reader-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 880px;
  margin-bottom: 16px;
}

.reader-subject {
  font-size: var(--text-2xl);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  outline: none;
}

.reader-count {
  flex: 0 0 auto;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.message-list,
.draft-list,
.attachment-list,
.compose-attachments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.message-list {
  max-width: 880px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.message + .message {
  border-top: 1px solid var(--line);
}

/* Folded */
.message-summary {
  display: grid;
  grid-template-columns: auto minmax(80px, max-content) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: var(--bg);
  text-align: left;
}

.message-summary:hover {
  background: var(--bg-hover);
}

.message-summary:focus-visible {
  outline-offset: -2px;
}

.message-summary .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.message-summary-from {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-summary-preview {
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-summary-clip {
  width: 15px;
  height: 15px;
  color: var(--fg-muted);
}

.message-summary-date {
  color: var(--fg-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.message.is-unread .message-summary-from {
  font-weight: 750;
}

/* Unfolded */
.message-article {
  padding: 16px 20px 20px;
}

.message-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.message-who {
  min-width: 0;
}

.message-from {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
}

.message-from-name {
  font-weight: 650;
  font-size: var(--text-md);
}

button.message-from-name {
  color: var(--fg);
}

.message-from-email {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.message-details summary {
  display: inline-block;
  max-width: 100%;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.message-details summary::-webkit-details-marker {
  display: none;
}

.message-details summary::after {
  content: " ▾";
  font-size: 10px;
}

.message-details[open] summary::after {
  content: " ▴";
}

.message-details dl {
  display: grid;
  gap: 2px;
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-app);
  font-size: var(--text-sm);
}

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

.detail-row dt {
  color: var(--fg-muted);
}

.detail-row dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0;
}

.message-date {
  margin-right: 6px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.message-meta .icon-button {
  width: 32px;
  height: 32px;
}

.message-body {
  margin: 14px 0 0 48px;
}

.message-text {
  max-width: 72ch;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-text a {
  overflow-wrap: anywhere;
}

.quoted-text {
  margin-top: 8px;
}

.quoted-text summary {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 8px;
  border-radius: 9px;
  background: var(--bg-hover);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
  list-style: none;
}

.quoted-text summary::-webkit-details-marker {
  display: none;
}

.message-text-quoted {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--fg-muted);
}

.message-html {
  display: grid;
  gap: 8px;
}

.message-frame {
  display: block;
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

/* Attachments */
.attachments {
  margin: 18px 0 0 48px;
}

.attachments-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.attachments-title .icon {
  width: 14px;
  height: 14px;
}

.attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-width: 760px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 4px 6px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.attachment-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.attachment-name {
  font-size: var(--text-sm);
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.attachment.is-error {
  border-color: var(--danger);
}

.attachment.is-error .attachment-size {
  color: var(--danger);
}

/* Drafts in this conversation */
.draft-list {
  display: grid;
  gap: 8px;
  max-width: 880px;
  margin-top: 12px;
}

.draft-card {
  padding: 12px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

.draft-card-head {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.draft-card-preview {
  margin: 4px 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draft-card-actions {
  display: flex;
  gap: 8px;
}

.reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 880px;
  margin-top: 16px;
}

/* No conversation open */
.reader-empty {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  color: var(--fg-muted);
  text-align: center;
}

.reader-empty-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  color: var(--line-strong);
  stroke-width: 1.4;
}

.reader-empty-heading {
  color: var(--fg);
  font-weight: 600;
}

.reader-empty-text {
  font-size: var(--text-sm);
}

.reader-skeleton {
  max-width: 720px;
}

@media (max-width: 1100px) {
  .reader-scroll {
    padding: 16px 20px 32px;
  }
}

@media (max-width: 760px) {
  .reader-toolbar {
    position: sticky;
    top: 0;
    padding: 6px 8px;
    min-height: 48px;
  }

  .reader-toolbar .button.is-small span {
    display: none;
  }

  .reader-toolbar .button.is-small {
    width: 36px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .reader-scroll {
    padding: 14px 12px 28px;
  }

  .reader-subject {
    font-size: var(--text-xl);
  }

  .message-list {
    border-radius: var(--radius);
  }

  .message-article {
    padding: 14px 14px 16px;
  }

  .message-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .message-meta {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-top: -6px;
  }

  .message-body,
  .attachments {
    margin-left: 0;
  }

  .message-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .message-summary-preview,
  .message-summary-clip {
    display: none;
  }
}
