:root {
  color-scheme: light;
  font: 15px/1.45 system-ui, sans-serif;
  color: #121c2d;
  background: #fff;
  --navy: #0e223b;
  --nav-selected: #243f60;
  --blue: #205eb9;
  --selection: #e3edfc;
  --line: #dbe0e7;
  --muted: #535e6c;
  --paper: #fdfcfb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid #548be5; outline-offset: 2px; }
button, input, textarea { border-radius: 3px; }
h1 { font-size: 1.65rem; letter-spacing: -.035em; }
.auth { min-height: 100dvh; display: grid; place-items: center; background: var(--paper); padding: 24px; }
.auth-panel { width: min(100%, 420px); }
.auth-panel p { margin: 10px 0 20px; }

.mail { display: grid; grid-template-columns: 212px minmax(290px, 32%) minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--navy); color: #fff; min-width: 0; }
.brand { margin: 0 6px 22px; font-size: 1.25rem; letter-spacing: -.025em; }
.primary, .outline { padding: 7px 16px; }
.primary { color: #fff; background: var(--blue); border: 1px solid transparent; }
.primary:hover { background: #174d9c; }
.compose { background: #3975d1; padding-block: 10px; font-weight: 600; }
.folders { margin-top: 18px; display: grid; gap: 4px; }
.folder, .account button { color: inherit; background: transparent; border: 0; text-align: left; }
.folder { padding: 9px 12px; }
.folder:hover, .folder[aria-current] { background: var(--nav-selected); }
.account { margin-top: auto; padding: 0 6px; display: grid; gap: 5px; font-size: .85rem; }
#mailbox { overflow-wrap: anywhere; }
.account button { color: #c8d5e5; padding: 0; justify-self: start; }
.account button:hover { text-decoration: underline; }

.inbox { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: var(--paper); overflow: auto; }
.list-header { background: var(--paper); position: sticky; top: 0; z-index: 1; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.outline { color: inherit; border: 1px solid #aab3bf; background: #fff; }
.outline:hover { background: #f0f4f9; }
#refresh { font-size: .8rem; padding: 4px 9px; }
#search { width: 100%; background: #fff; border: 1px solid #aab3bf; padding: 8px 10px; color: inherit; }
.row { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; text-align: left; padding: 9px 18px; gap: 1px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: inherit; position: relative; }
.row:hover { background: #f1f5fc; }
.row[aria-pressed=true] { background: var(--selection); box-shadow: inset 3px 0 #3975d1; }
.row:focus-visible { outline-offset: -3px; }
.row .row-person, .row .row-subject, .row .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-person { font-weight: 650; }
.row-subject, .preview { grid-column: 1 / -1; }
.row.unread .row-person::before { content: ""; width: 7px; height: 7px; display: inline-block; border-radius: 50%; margin-right: 7px; background: #2866ba; vertical-align: 2px; }
.row.unread .row-subject { font-weight: 700; }
.row time, .preview, .muted { color: var(--muted); }
.row time, .preview { font-size: .84rem; }
.more { margin: 12px auto; }
.empty { padding: 18px; color: var(--muted); }

.reader { min-width: 0; overflow: auto; padding: 23px 28px; }
.reader h2 { font-size: clamp(1.55rem, 2.6vw, 2.2rem); line-height: 1.2; letter-spacing: -.035em; overflow-wrap: anywhere; }
.message-header { display: flex; align-items: start; gap: 8px 20px; justify-content: space-between; flex-wrap: wrap; padding: 21px 0 15px; border-bottom: 1px solid #cfd5de; }
.message-addresses { min-width: 0; overflow-wrap: anywhere; }
#sender strong { margin-right: .4em; }
#time { font-size: .85rem; padding-top: 2px; }
.body { padding: 21px 0 24px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 80ch; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 16px; list-style: none; }
.attachments:empty { display: none; }
.attachments button { overflow-wrap: anywhere; max-width: 100%; }
.back { display: none; }

.notice { position: fixed; right: 24px; bottom: 24px; background: var(--navy); color: #fff; padding: 9px 14px; border-radius: 3px; max-width: calc(100% - 48px); }
#editor { padding: 0; border: 1px solid #aab3bf; border-radius: 4px; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto 24px 16px auto; color: inherit; box-shadow: 0 8px 32px #101f342f; }
#editor::backdrop { background: #101f3424; }
.editor-header { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: white; padding: 10px 15px; }
.editor-header h2 { font-size: 1rem; }
.editor-header button { color: inherit; background: transparent; border: 0; padding: 0 5px; font-size: 1.35rem; }
.editor-fields { padding: 0 15px; }
.field { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field > span:first-child { flex: 0 0 56px; color: var(--muted); }
.field input { border: 0; flex: 1; min-width: 0; color: inherit; }
textarea { display: block; resize: vertical; width: 100%; min-height: 160px; padding: 10px 0; border: 0; color: inherit; }
.editor-footer { display: flex; align-items: center; padding: 11px 15px; gap: 12px; border-top: 1px solid var(--line); }
#send-error { color: #982b2b; font-size: .88rem; }

@media (max-width: 950px) {
  .mail { grid-template-columns: 162px minmax(255px, 34%) minmax(0, 1fr); }
  .reader { padding-inline: 19px; }
}
@media (max-width: 720px) {
  .mail { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 7px 10px; padding: 10px; }
  .brand { margin: 0 auto 0 0; font-size: 1.05rem; }
  .compose { padding: 6px 10px; }
  .folders { display: flex; margin: 0; }
  .folder { padding: 6px 9px; }
  .account { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; margin: 0; }
  .inbox { border-right: 0; }
  .reader { display: none; }
  .mail.reading .reader { display: block; }
  .mail.reading .inbox { display: none; }
  .back { display: inline-block; margin-bottom: 15px; }
  #editor { width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; }
  #write { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .editor-fields { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); min-height: 0; }
  textarea { min-height: 0; resize: none; }
}
