/* Attachment discovery and reading preferences; load after browsing.css. */

.message-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
}

.row-identity {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 50%;
  color: #607b92;
  background: #edf2f7;
}

.row-identity .avatar {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.row-identity svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.6;
}

.sent-identity {
  color: #527694;
  background: #eef4f9;
}

.document-identity {
  border-radius: 7px;
  color: #5b7290;
  background: #eef2f7;
}

.row-main {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.row-top {
  gap: 8px;
  margin-bottom: 4px;
}

.row-sender {
  min-width: 0;
  color: #51677b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.row-date {
  flex: 0 0 auto;
  font-size: 11px;
}

.row-subject {
  color: #23394e;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.row-snippet {
  color: #607285;
}

.row-files {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  margin-top: 8px;
}

.row-files:empty {
  display: none;
}

.row-file {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 3px 6px;
  overflow: hidden;
  border: 1px solid #dce5ed;
  border-radius: 5px;
  background: #f8fafc;
  color: #4c647a;
  font-size: 11px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-file-kind {
  display: inline-block;
  margin-right: 5px;
  color: #356484;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .15px;
}

.row-file-more,
.row-unavailable {
  color: #607285;
  font-size: 11px;
  line-height: 1.5;
}

.row-file-more {
  flex: 0 0 auto;
}

.row-foot {
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 7px;
  line-height: 1.5;
}

.row-foot .row-attachment {
  min-width: 0;
}

.message-row.selected .row-sender {
  color: #42627f;
}

.message-row.selected .row-file {
  border-color: #c7daec;
  background: #f5f9fe;
}

/* Compact rows keep counts and search excerpts without repeating filenames. */
.message-list.compact-list .message-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.message-list.compact-list .row-identity,
.message-list.compact-list .row-files {
  display: none;
}

.message-list.compact-list .row-sender {
  font-size: 12px;
  font-weight: 500;
}

.message-list.compact-list .row-subject {
  font-size: 13px;
  font-weight: 600;
}

.message-list.compact-list .row-foot {
  gap: 4px 8px;
}

.list-tools {
  flex-wrap: wrap;
  gap: 4px 8px;
}

.files-button,
#readingOptions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  color: #526d84;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.files-button {
  max-width: 160px;
}

.files-button > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-button svg,
#readingOptions svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  stroke-width: 1.6;
}

.files-button.active,
.files-button[aria-pressed="true"],
#readingOptions[aria-expanded="true"] {
  background: #eaf3fc;
  color: #185d94;
}

.files-button:disabled {
  opacity: .45;
  cursor: default;
}

.files-dialog,
.reading-dialog {
  width: calc(100% - 32px);
  padding: 28px;
  border-color: #dbe4ec;
  border-radius: 12px;
  background: #fff;
}

.files-dialog {
  max-width: 480px;
}

.reading-dialog {
  max-width: 360px;
}

.files-dialog h2,
.reading-dialog h2 {
  padding-right: 28px;
  font-size: 22px;
  line-height: 1.35;
}

.files-dialog .dialog-close,
.reading-dialog .dialog-close {
  top: 8px;
  right: 8px;
  width: 44px;
  min-width: 44px;
  height: 44px;
}

.file-options {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.file-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: start;
  gap: 11px;
  min-height: 64px;
  padding: 13px 12px;
  border: 1px solid #e0e7ee;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.file-option:hover {
  background: #f7fafd;
}

.file-option:has(input:checked),
.file-option.selected {
  border-color: #b6d3e9;
  background: #edf5fc;
}

.file-option:focus-within {
  outline: 2px solid #2877b2;
  outline-offset: 2px;
}

.file-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

.file-option-copy {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-option-copy strong {
  display: block;
  color: #294359;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.file-option-copy > span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.file-option-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px;
  margin-top: 1px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #f0f3f6;
  color: #556e83;
  font-size: 12px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.file-option:has(input:checked) .file-option-count {
  background: #dfeefa;
  color: #2c6490;
}

.files-dialog .file-count-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.reading-preference-title {
  display: block;
  margin: 20px 0 9px;
  color: #3b5369;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.reading-dialog .reader-text-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 5px;
  border-color: #dce5ed;
  background: #f6f8fb;
}

.reading-dialog .reader-text-controls button {
  width: 48px;
  min-width: 48px;
  min-height: 44px;
  padding: 8px;
  font-size: 15px;
}

.reading-dialog #readingSize {
  position: static;
  display: block;
  flex: 1;
  width: auto;
  height: auto;
  min-width: 0;
  padding: 0 4px;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: #536b80;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  white-space: normal;
}

.reader {
  background: #f5f7fa;
}

.email-sheet {
  border-color: #e5ebf1;
  border-radius: 12px;
  box-shadow: 0 1px 3px #17324b04;
}

@media (max-width: 820px) {
  .message-row {
    gap: 10px;
    padding-inline: 16px;
  }

  .row-sender {
    font-size: 13px;
  }

  .row-subject {
    font-size: 14px;
  }

  .row-file,
  .row-file-more,
  .row-unavailable {
    font-size: 12px;
  }

  .message-list.compact-list .row-sender {
    font-size: 12px;
  }

  .list-tools {
    padding-inline: 16px;
  }

  .files-button {
    max-width: 150px;
    padding-inline: 7px;
  }

  .reader-actions #readingOptions {
    min-height: 44px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .reader {
    background: #fff;
  }

  .email-sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 420px) {
  .reader-actions #readingOptions {
    width: 44px;
    min-width: 44px;
    padding: 8px;
  }

  #readingOptions > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .files-dialog,
  .reading-dialog {
    padding: 26px 20px;
  }

  .file-option {
    gap: 9px;
    padding-inline: 10px;
  }
}

@media (max-width: 360px) {
  .files-button {
    max-width: 135px;
  }

  .row-top {
    gap: 6px;
  }
}

.files-dialog .dialog-actions { justify-content: flex-end; }

.search-help-button { flex: 0 0 32px; min-width: 32px; width: 32px; height: 32px; }
.search-help-button svg { width: 19px; height: 19px; }
.search-help-dialog { max-width: 480px; }
.search-help-dialog h2 { padding-right: 22px; font-size: 22px; }
.search-examples { margin: 22px 0; }
.search-examples > div + div { margin-top: 21px; }
.search-examples dt { font-size: 14px; font-weight: 650; color: var(--ink); }
.search-examples dd { margin: 8px 0 0; }
.search-examples code { display: inline-block; padding: 5px 8px; background: #edf3f8; border-radius: 5px; font-size: 12px; color: #244963; }
.search-examples dd span { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.search-help-scope { border-top: 1px solid var(--line); padding-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.search-help-shortcut { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.search-help-shortcut kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; }
@media (max-width: 820px) {
  .search-help-button { flex-basis: 36px; min-width: 36px; width: 36px; height: 40px; }
  .search-help-shortcut { display: none; }
}
