:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 15px;
  color: #202824;
  background: #f5f7f5;
  --paper: #fff;
  --side: #f4f7f5;
  --line: #e0e7e2;
  --ink: #202824;
  --muted: #516159;
  --green: #285945;
  --green-hover: #204a39;
  --selected: #e6f0ea;
  --hover: #edf3ef;
  --error: #8a2622;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100dvh; }
section, article, div { min-width: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
input, textarea { caret-color: var(--green); }
::selection { background: #d1e6d0; color: var(--ink); }
:focus-visible { outline: 2px solid #3f7358; outline-offset: 3px; }
h1, h2, p { margin: 0; }
.symbols { display: none; }
svg:not(.symbols) {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round;
}

.auth-header, .app-header {
  height: 68px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding-inline: 32px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.0625rem; font-weight: 700; white-space: nowrap; }
.brand-mark {
  width: 31px; height: 31px; border-radius: 8px; background: var(--green); color: white;
  display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.auth-domain, .account { font-size: .875rem; color: var(--muted); }
.auth-scene { min-height: 100dvh; background: var(--side); }
.auth-header { background: var(--paper); }
.auth-content {
  min-height: calc(100dvh - 68px); display: grid; justify-items: center;
  align-items: start; padding: min(16vh, 148px) 24px 44px;
}
.auth-form { width: min(100%, 376px); }
.auth-form h1 { font-size: 2.55rem; letter-spacing: -.035em; font-weight: 720; }
.intro { color: var(--muted); line-height: 1.65; margin: 13px 0 30px; }
.auth-switch { margin-top: 26px; color: var(--muted); font-size: .9rem; }
.text-button { padding: 0; border: 0; color: var(--green); font-weight: 700; background: none; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--green-hover); }
.boot { display: grid; min-height: 100dvh; place-items: center; color: var(--muted); padding: 28px; text-align: center; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  text-decoration: none; background: transparent; font-size: .9rem; font-weight: 620;
  transition: background-color 150ms ease, color 150ms ease;
}
.button:hover { background: var(--hover); }
.button.quiet { border-color: transparent; color: var(--muted); }
.button.primary { color: #fff; border-color: var(--green); background: var(--green); }
.button.primary:hover { background: var(--green-hover); }
.button.full { width: 100%; min-height: 48px; }
a.button.full { justify-content: space-between; padding-inline: 15px; }
label { display: block; font-weight: 650; margin: 0 0 7px; }
input, textarea {
  width: 100%; border: 1px solid #b9c6b9; border-radius: 8px;
  padding: 11px 12px; color: var(--ink); background: var(--paper);
}
input, .address-field { min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.address-field {
  display: flex; align-items: center; border: 1px solid #b9c6b9; border-radius: 8px;
  background: var(--paper);
}
.address-field:focus-within { outline: 2px solid #3f7358; outline-offset: 3px; }
.address-field input { min-width: 0; border: 0; outline: 0; background: transparent; }
.address-field span { color: var(--muted); padding-inline: 4px 12px; font-size: .9rem; white-space: nowrap; }
.field-help { color: var(--muted); margin: 7px 0 17px; font-size: .875rem; line-height: 1.5; }
.form-status { margin: 12px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.6; }
.error { color: var(--error) !important; }

.mail-app { --rail: 196px; --header-height: 68px; min-height: 100dvh; background: var(--paper); }
.mail-header {
  display: grid;
  grid-template-columns: calc(var(--rail) - 24px) minmax(176px, 470px) 1fr;
  align-items: center; gap: 16px; padding-inline: 22px;
  height: var(--header-height); border-bottom: 1px solid var(--line);
}
.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mail-header .account { justify-self: end; max-width: 100%; }
.account > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { flex: none; min-height: 36px; }
.workspace {
  display: grid;
  grid-template-columns: var(--rail) clamp(312px, 28vw, 418px) minmax(0, 1fr);
  min-height: calc(100dvh - var(--header-height));
}
.mail-navigation {
  display: flex; flex-direction: column; gap: 20px; padding: 19px 13px;
  background: var(--side); border-right: 1px solid var(--line);
}
.mail-list {
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--paper); border-right: 1px solid var(--line);
}
.folders { display: flex; flex-direction: column; gap: 4px; }
.folder {
  display: inline-flex; align-items: center; gap: 9px; background: transparent; border: 0;
  border-radius: 7px; min-height: 41px; padding: 0 10px; text-align: left;
  font-size: .875rem; font-weight: 620; color: var(--muted); white-space: nowrap;
}
.folder:hover { background: var(--hover); }
.folder[aria-current] { background: var(--selected); color: var(--green); font-weight: 700; }
.folder svg { width: 16px; height: 16px; }
.unread-count { margin-inline-start: auto; color: var(--green); font-size: .8rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.write { white-space: nowrap; justify-content: flex-start; padding-inline: 12px; min-height: 44px; }
.search-form {
  display: flex; align-items: center; gap: 3px;
  background: var(--side); border: 1px solid var(--line); border-radius: 8px;
}
.search-form:focus-within { outline: 2px solid #3f7358; outline-offset: 2px; }
.search-form input { min-width: 0; min-height: 40px; padding: 8px 12px; border: 0; background: transparent; outline: 0; font-size: .9rem; }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-form .icon-button { flex: none; margin-inline-end: 2px; }
.clear-search { flex: none; min-height: 30px; padding-inline: 5px; font-size: .85rem; }
.list-heading {
  display: flex; align-items: center; justify-content: space-between; padding: 17px 18px 16px; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.list-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.unread-filter { min-height: 36px; padding-inline: 9px; font-size: .8rem; }
.unread-filter[aria-pressed="true"] { background: var(--selected); color: var(--green); border-color: #a4b8a6; }
.list-heading h1 { font-size: 1.3rem; letter-spacing: -.018em; display: flex; align-items: baseline; gap: 8px; }
#total { font-size: .84rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-button {
  display: grid; place-items: center; border: 0; border-radius: 7px; width: 36px; height: 36px;
  background: transparent; color: var(--muted);
}
.icon-button:hover { background: var(--hover); color: var(--ink); }
.list-scroll { overflow: auto; padding: 0 0 20px; scrollbar-color: #b9c7bb transparent; }
.messages { list-style: none; padding: 0; margin: 0; }
.messages li { border-bottom: 1px solid var(--line); }
.message {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px; width: 100%; padding: 13px 18px 13px 27px;
  background: transparent; border: 0; color: var(--ink); text-align: left;
}
.message:hover { background: var(--hover); }
.message[aria-current] { background: var(--selected); }
.message:focus-visible { outline-offset: -3px; }
.message > span, .message time { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.message .person { display: flex; align-items: center; font-size: .825rem; color: var(--muted); }
.message .person span { overflow: hidden; text-overflow: ellipsis; }
.message time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.message .subject { grid-column: 1 / -1; font-size: .93rem; font-weight: 560; }
.message .preview { grid-column: 1 / -1; font-size: .82rem; line-height: 1.5; color: var(--muted); }
.message.unread .subject { font-weight: 760; }
.message.unread::before {
  content: ""; position: absolute; inset: 19px auto auto 13px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
}
.list-status, .reader-status { color: var(--muted); line-height: 1.6; }
.list-status { padding: 21px 18px; font-size: .92rem; }
.more { width: calc(100% - 36px); margin: 14px 18px 0; }

.reading { display: flex; flex-direction: column; min-width: 0; overflow: auto; background: var(--paper); }
.reader-empty { margin: auto; text-align: center; padding: 40px 22px; color: var(--muted); }
.reader-empty h2 { margin-bottom: 7px; color: var(--ink); font-size: 1.35rem; letter-spacing: -.015em; }
.reader-empty p { font-size: .92rem; line-height: 1.6; }
.reader-status { padding: 36px 38px; }
.letter, .compose { width: min(100%, 980px); padding: 25px clamp(23px, 3.15vw, 52px) 48px; }
.letter-heading { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 10px 16px; }
.letter h2, .compose h2 { font-size: 1.75rem; letter-spacing: -.025em; line-height: 1.35; overflow-wrap: anywhere; }
.letter h2 { flex: 1 1 250px; }
#letter-subject:focus { outline: none; }
.letter-meta {
  display: flex; justify-content: space-between; gap: 8px 16px; margin-top: 20px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere;
}
.letter-meta span { font-weight: 680; }
.letter-meta p, .letter-meta time { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.letter-meta time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.letter-body { padding: 24px 0 5px; max-width: 68ch; line-height: 1.82; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.letter-actions .button { min-height: 36px; padding-inline: 10px; }
.compose-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 23px; }
.compose input#subject { margin-bottom: 16px; }
.compose textarea { resize: vertical; min-height: 155px; line-height: 1.65; }
.compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; margin-top: 16px; }
.compose-actions .form-status { margin: 0; }
.back { display: none; }
.toast {
  position: fixed; max-width: calc(100vw - 32px); bottom: 22px; right: 22px; z-index: 2;
  padding: 12px 16px; background: var(--green); color: #fff; border-radius: 9px; font-size: .9rem;
}

@media (min-width: 751px) {
  .workspace { height: calc(100dvh - var(--header-height)); }
  .mail-navigation, .mail-list, .reading { min-height: 0; }
  .mail-navigation { overflow: auto; }
}

@media (min-width: 751px) and (max-width: 1040px) {
  .mail-app { --rail: 160px; }
  .workspace { grid-template-columns: var(--rail) minmax(270px, 31vw) minmax(0, 1fr); }
  .mail-navigation { padding-inline: 10px; }
  .mail-header { grid-template-columns: calc(var(--rail) - 24px) minmax(150px, 340px) 1fr; }
  .letter h2 { flex-basis: 100%; }
  .letter-meta { flex-wrap: wrap; }
}

@media (max-width: 750px) {
  .auth-header { height: 60px; padding-inline: 16px; }
  .auth-content { min-height: calc(100dvh - 60px); padding-top: min(12vh, 94px); }
  .auth-form h1 { font-size: 2.125rem; }
  .brand { font-size: .96rem; gap: 7px; }
  .account { gap: 8px; font-size: .78rem; }
  .logout { gap: 4px; min-height: 34px; padding: 0 7px; font-size: .78rem; }
  .logout svg { width: 15px; height: 15px; }
  .mail-header {
    height: auto; min-height: 60px; grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(38px, auto) auto; gap: 6px 12px; padding: 9px 16px 12px;
  }
  .mail-header .search-form { grid-column: 1 / -1; grid-row: 2; }
  .mail-header .account { grid-column: 2; grid-row: 1; }
  .workspace { display: block; min-height: 0; }
  .mail-navigation {
    flex-direction: row; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .folders { flex-direction: row; gap: 3px; }
  .folder { gap: 5px; padding-inline: 8px; }
  .unread-count { margin-inline-start: 0; }
  .mail-list { display: block; border-right: 0; }
  .list-heading { padding: 12px 14px 12px 17px; }
  .unread-filter, .list-actions .icon-button { min-height: 40px; }
  .reading { display: none; }
  .mail-app.reading-open .mail-header { grid-template-rows: minmax(38px, auto); padding-bottom: 9px; }
  .mail-app.reading-open .search-form, .mail-app.reading-open .mail-navigation, .mail-app.reading-open .mail-list { display: none; }
  .mail-app.reading-open .reading { display: flex; min-height: calc(100dvh - 60px); }
  .back { display: inline-flex; align-self: flex-start; margin: 14px 18px 0; }
  .letter, .compose, .reader-status { padding: 20px 18px 36px; }
  .letter h2 { flex-basis: 100%; font-size: 1.5rem; }
  .letter-meta { flex-wrap: wrap; }
  .letter-body { padding-top: 21px; }
}

@media (max-width: 360px) {
  .mail-navigation { padding-inline: 9px; gap: 4px; }
  .folder { padding-inline: 6px; gap: 4px; }
  .write { padding-inline: 8px; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
