:root {
  color-scheme: light;
  font: 100%/1.5 system-ui, sans-serif;
  color: #242939;
  background: #f3f5fa;
  --paper: #fff;
  --line: #dce1ed;
  --accent: #273986;
  --accent-soft: #eaf0ff;
  --muted: #545f76;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.masthead {
  min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between;
  padding: .8rem clamp(1rem, 4vw, 3.25rem); gap: 1rem;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-size: 1.13rem; font-weight: 700; }
.mark { display: grid; place-items: center; width: 2rem; height: 2rem; background: var(--accent); color: white; border-radius: .55rem; }
.account { display: flex; align-items: center; gap: .75rem; min-width: 0; font-size: .9rem; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { padding: clamp(1rem, 3vw, 2.5rem); }
.login-panel {
  width: min(100%, 27rem); margin: clamp(2rem, 10vh, 7rem) auto 0;
  padding: clamp(1.25rem, 4vw, 2.25rem); border-radius: 1rem;
  border: 1px solid var(--line); background: var(--paper); box-shadow: 0 1rem 3rem #25305b13;
}
h1, h2 { margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.login-panel h1 { font-size: 1.75rem; margin-bottom: 1.6rem; }
form { display: grid; gap: .65rem; }
label { font-size: .95rem; font-weight: 650; }
input, textarea, button { font: inherit; }
input, textarea {
  width: 100%; border: 1px solid #aebad0; border-radius: .55rem;
  background: white; color: inherit; padding: .65rem .8rem; margin-bottom: .5rem;
}
textarea { resize: vertical; min-height: 7rem; }
button { border: 1px solid transparent; border-radius: .55rem; padding: .55rem .8rem; cursor: pointer; font-weight: 650; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: #1b2863; }
.quiet, .folders button { background: transparent; color: var(--accent); }
.quiet:hover, .folders button:hover, .folders [aria-current] { background: var(--accent-soft); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #6079dd; outline-offset: 2px; }
.mailbox {
  min-height: calc(100vh - 10rem); display: grid; grid-template-columns: 12rem minmax(17rem, 25rem) minmax(0, 1fr);
  border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); overflow: hidden;
}
.sidebar { padding: 1rem .8rem; background: #f8f9fd; border-right: 1px solid var(--line); }
.sidebar .primary { width: 100%; }
.folders { display: grid; gap: .3rem; margin-top: 1.25rem; }
.folders button { text-align: left; }
.mail-list { min-width: 0; border-right: 1px solid var(--line); }
.list-head, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.list-head { border-bottom: 1px solid var(--line); padding: .9rem .7rem .9rem 1rem; }
.list-head h1 { font-size: 1.12rem; }
.list-head .quiet { font-size: .88rem; }
#messages { padding: 0; margin: 0; list-style: none; }
#messages li { border-bottom: 1px solid var(--line); }
.message-row { display: grid; width: 100%; padding: .8rem 1rem; color: inherit; background: white; text-align: left; border-radius: 0; gap: .15rem; }
.message-row:hover, .message-row[aria-current] { background: var(--accent-soft); }
.message-row span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.meta { color: var(--muted); font-size: .88rem; font-weight: 450; }
.reader { min-width: 0; padding: clamp(1rem, 3vw, 2rem); }
.envelope { margin: 1.25rem 0; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.envelope div { display: grid; grid-template-columns: 4rem minmax(0, 1fr); margin-bottom: .25rem; }
.envelope dt, .status { color: var(--muted); }
.envelope dd { margin: 0; overflow-wrap: anywhere; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.status { margin: .4rem 0 0; min-height: 1.5em; }
.mail-list .status, .pagination { padding: .65rem 1rem; }
.pagination { display: flex; justify-content: space-between; }
.notice { padding: .75rem 1rem; border-radius: .55rem; background: var(--accent-soft); }
dialog { border: 1px solid var(--line); border-radius: .85rem; color: inherit; width: min(calc(100% - 2rem), 38rem); padding: 1.4rem; }
dialog::backdrop { background: #131a3c80; }
@media (max-width: 950px) {
  .mailbox { grid-template-columns: minmax(15rem, 22rem) minmax(0, 1fr); }
  .sidebar { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; border: 0; border-bottom: 1px solid var(--line); }
  .sidebar .primary { width: auto; }
  .folders { display: flex; margin-top: 0; }
}
@media (max-width: 620px) {
  .masthead { flex-wrap: wrap; }
  .sidebar, .folders { flex-wrap: wrap; }
  .mailbox { grid-template-columns: minmax(0, 1fr); min-height: 70vh; }
  .mail-list { border-right: 0; }
  .mailbox:not(.has-message) .reader, .mailbox.has-message .mail-list { display: none; }
  .mailbox.has-message #back { display: inline-block; margin-bottom: 1rem; }
}
@media (min-width: 621px) {
  #back { display: none; }
}
