.folder {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 30px;
  align-items: center;
}

.folder[hidden],
[data-admin-entry][hidden] {
  display: none !important;
}

.tracking-shield {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 24px 0 12px;
  padding: 8px 12px;
  border: 1px solid #b9d9c9;
  border-radius: 999px;
  background: #effaf4;
  color: #276348;
  font-size: 13px;
}

.tracking-shield .icon {
  width: 17px;
  height: 17px;
}

.tracking-shield button {
  margin-left: 4px;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: #276348;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.avatar[data-bimi-domain] {
  position: relative;
  overflow: visible;
}

.avatar[data-bimi-domain] > img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

.bimi-badge {
  position: absolute;
  right: -4px;
  bottom: -3px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #18764e;
  color: #fff;
}

.bimi-badge .icon {
  width: 11px;
  height: 11px;
}

.message-html {
  display: block;
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bimi-card a {
  color: var(--deep);
  font-weight: 700;
}

@media (max-width: 960px) {
  .admin-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.folder > b {
  margin-left: 0;
  min-width: 26px;
  justify-self: end;
  text-align: center;
}

[data-count="sent"] {
  display: none !important;
}

@media (min-width: 701px) and (max-width: 920px) {
  .folder {
    position: relative;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .folder > b {
    position: absolute;
    right: -3px;
    top: 2px;
  }
}

@media (max-width: 700px) {
  .mailroom.menu-open .folder {
    grid-template-columns: 20px minmax(0, 1fr) 30px;
    justify-items: stretch;
  }
}

.user-dialog .address-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.user-dialog .address-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
}

.user-dialog .address-field small {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  background: var(--mist);
}

.user-dialog form,
.compose-dialog form {
  max-height: min(860px, calc(100dvh - 24px));
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.compose-dialog {
  max-height: calc(100dvh - 16px);
  overflow: hidden;
}

body:has(.compose-dialog[open]) {
  overflow: hidden;
}

.compose-dialog form {
  width: min(760px, calc(100vw - 28px));
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.compose-address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.sender-mode {
  position: relative;
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.sender-mode-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}

.sender-mode-trigger small {
  color: var(--muted);
  font-weight: 400;
}

.sender-mode-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 35px rgb(9 41 59 / 18%);
}

.sender-mode-menu[hidden] { display: none !important; }
.sender-mode-menu button { display: grid; width: 100%; gap: 2px; padding: 10px; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; }
.sender-mode-menu button:hover { background: var(--mist); }
.sender-mode-menu small,.sender-mode-menu p { color: var(--muted); font-size: 12px; font-weight: 400; }

.compose-editor {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #eef5f8;
}

.editor-toolbar button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.editor-toolbar button:hover,
.editor-toolbar button:focus-visible,
.editor-toolbar button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px #17394b16;
}

.editor-toolbar button.is-active {
  color: var(--blue);
}

.editor-toolbar > span {
  width: 1px;
  height: 24px;
  margin: 6px 4px;
  background: var(--line);
}

.editor-surface,
.mail-editor-content {
  min-height: 300px;
}

.editor-surface {
  cursor: text;
}

.mail-editor-content {
  padding: 20px;
  outline: 0;
  color: var(--ink);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.mail-editor-content p {
  margin: 0 0 1em;
}

.mail-editor-content p:last-child {
  margin-bottom: 0;
}

.mail-editor-content ul,
.mail-editor-content ol {
  padding-left: 1.6em;
}

.mail-editor-content blockquote {
  margin: 1em 0;
  padding-left: 14px;
  border-left: 3px solid var(--blue);
  color: var(--muted);
}

.mail-editor-content a {
  color: var(--blue);
  text-decoration: underline;
}

.mail-formula {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 0 3px;
  padding: 3px 8px;
  border: 1px solid #b9d4e0;
  border-radius: 6px;
  background: #eef7fa;
  color: var(--ink);
  font-family: Cambria Math, STIX Two Math, Georgia, serif;
  font-size: 1.05em;
  cursor: pointer;
  user-select: all;
}

.mail-formula:hover,
.mail-formula:focus {
  border-color: var(--blue);
  outline: 2px solid rgb(45 139 180 / 18%);
}

.formula-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, .45fr);
  gap: 14px 18px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: #f7fbfc;
}

.formula-panel[hidden] {
  display: none !important;
}

.formula-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.formula-heading > div {
  display: grid;
  gap: 3px;
}

.formula-heading strong {
  color: var(--ink);
  font-size: 16px;
}

.formula-heading span,
.formula-panel output small {
  color: var(--muted);
  font-size: 11px;
}

.formula-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.formula-presets {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.formula-presets button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
}

.formula-presets button:hover,
.formula-presets button:focus-visible {
  border-color: var(--blue);
  background: #eaf5f9;
}

.formula-panel label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.formula-input {
  min-height: 48px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.formula-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(45 139 180 / 14%);
}

.formula-input:empty::before {
  content: attr(data-placeholder);
  color: #8da0aa;
  pointer-events: none;
}

.formula-panel output {
  display: grid;
  min-height: 72px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: Cambria Math, STIX Two Math, Georgia, serif;
}

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

.formula-actions button {
  min-height: 40px;
}

.editor-help {
  display: none;
}

[data-editor-html] {
  display: none !important;
}

.compose-dialog .draft-delete {
  margin-right: auto;
  border: 1px solid #efb4aa;
  background: #fff5f3;
  color: #a83f31;
}

.thread-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: #dcebf2;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.alias-list { display: grid; gap: 10px; margin-top: 20px; }
.alias-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.alias-row > span { display: grid; gap: 4px; min-width: 0; }
.alias-row small { color: var(--muted); overflow-wrap: anywhere; }
.status-pill { padding: 5px 9px; border-radius: 999px; font-size: 11px; }
.status-pill.is-ready { background: #e5f7ee; color: #16714a; }
.status-pill.is-off { background: #edf1f3; color: var(--muted); }
.token-secret { margin-top: 18px; padding: 16px; border-radius: 10px; background: #102f40; color: #dff7ee; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.alias-dialog form,.token-dialog form { width: min(560px, calc(100vw - 28px)); }
.password-dialog form { width: min(480px, calc(100vw - 28px)); }
.user-row { grid-template-columns: 42px minmax(180px,1fr) 120px auto 72px; }
.user-row [data-reset-password] { border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; background: var(--paper); color: var(--deep); font-weight: 700; white-space: nowrap; }
.sender-kind { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.sender-kind legend { margin-bottom: 8px; font-weight: 700; }
.sender-kind label { position: relative; cursor: pointer; }
.sender-kind input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.sender-kind span { display: grid; gap: 3px; min-height: 72px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); transition: border-color .18s ease,box-shadow .18s ease,transform .18s ease; }
.sender-kind small { color: var(--muted); }
.sender-kind input:checked + span { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb,var(--blue) 16%,transparent); transform: translateY(-1px); }
.sender-kind input:focus-visible + span { outline: 3px solid color-mix(in srgb,var(--blue) 28%,transparent); outline-offset: 2px; }
@media (max-width:560px) { .sender-kind { grid-template-columns: 1fr; } }
@media (max-width:650px) {
  .user-row { grid-template-columns: 40px minmax(0,1fr) auto; }
  .user-row select { grid-column: 2; }
  .user-row [data-reset-password] { grid-column: 2; width: max-content; }
  .user-row .danger-button { grid-column: 3; grid-row: 1 / 4; }
}

.conversation-head {
  padding-bottom: 24px;
}

.thread-stack {
  display: grid;
  gap: 18px;
}

.thread-message {
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.thread-message > header,
.thread-message > header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thread-message > header {
  justify-content: space-between;
}

.thread-message > header p {
  display: grid;
  margin: 0;
}

.thread-message > header small,
.message-route dt {
  color: var(--muted);
}

.direction-pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--mist);
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

.message-route {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--mist);
}

.message-route div {
  min-width: 0;
}

.message-route dt {
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 800;
}

.message-route dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.close-button .icon {
  transition: none !important;
  transform: none !important;
}

body[data-not-found="true"] {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--ink) 0 42%, var(--mist) 42% 100%);
}

body[data-not-found="true"] .site-header,
body[data-not-found="true"] .site-footer {
  display: none;
}

body[data-not-found="true"] .not-found-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body[data-not-found="true"] .not-found-panel {
  width: min(720px, 100%);
  padding: clamp(34px, 7vw, 72px);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 80px rgb(9 41 59 / 28%);
}

body[data-not-found="true"] .not-found-panel h1 {
  font: 700 clamp(36px, 7vw, 68px) "Noto Serif SC", serif;
  margin: 0 0 18px;
}

body[data-not-found="true"] .not-found-panel .button-link {
  display: inline-flex;
  margin-top: 18px;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--deep);
  color: #fff;
  text-decoration: none;
}

@media (max-width: 620px) {
  .admin-overview {
    grid-template-columns: 1fr;
  }

  .compose-dialog form {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .compose-address-row,
  .message-route {
    grid-template-columns: 1fr;
  }

  .editor-surface,
  .mail-editor-content {
    min-height: 220px;
  }

  .editor-toolbar {
    padding: 8px;
  }

  .editor-toolbar button {
    width: 34px;
    height: 34px;
  }

  .formula-panel {
    grid-template-columns: 1fr;
  }

  .thread-message {
    padding: 16px;
  }

  .alias-row { grid-template-columns: minmax(0, 1fr) auto; }
  .alias-row .danger-button { grid-column: 1 / -1; }

  .compose-dialog header,
  .compose-dialog label,
  .compose-dialog .attachment-picker,
  .compose-dialog footer {
    grid-column: 1;
  }
}
