:root {
  color-scheme: light dark;
  --bg: light-dark(#fff, #182226);
  --paper: light-dark(#f6f8f8, #121a1e);
  --ink: light-dark(#233238, #e3eef0);
  --muted: light-dark(#5e7077, #a5b7bc);
  --line: light-dark(#e1e8e9, #34454b);
  --accent: light-dark(#176b55, #8bdcc1);
  --accent-soft: light-dark(#e5f3ee, #243e37);
  --solid: light-dark(#1b705b, #287c62);
  --on-solid: #fff;
  --error: light-dark(#a02f36, #ffb6b8);
  font:
    14px/1.55 Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}
button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}
button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
}
button,
input,
select,
textarea {
  background: var(--bg);
}
input,
select,
textarea {
  min-width: 0;
  padding: 8px 11px;
}
textarea {
  resize: vertical;
}
button {
  cursor: pointer;
  padding: 7px 12px;
  min-height: 35px;
}
button:hover:not(:disabled) {
  background: var(--paper);
}
button:disabled {
  cursor: default;
  opacity: 0.52;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary {
  background: var(--solid);
  color: var(--on-solid);
  border-color: transparent;
}
button.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--solid), #111 12%);
}
button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
button.quiet {
  border-color: transparent;
}
a {
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 18px;
  font-weight: 650;
}
h3 {
  font-size: 14px;
  font-weight: 650;
}
pre {
  font: inherit;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.error {
  color: var(--error);
}
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.spread {
  justify-content: space-between;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.035em;
}
.brand-mark {
  width: 30px;
  height: 30px;
  margin-right: 10px;
  display: grid;
  place-items: center;
  background: var(--solid);
  color: var(--on-solid);
  border-radius: 9px;
  font-size: 21px;
  line-height: 1;
}
.brand-dot {
  color: var(--accent);
}
#primary-nav {
  align-self: stretch;
  display: flex;
  gap: 14px;
}
#primary-nav button {
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  border-bottom: 2px solid transparent;
}
#primary-nav button[aria-current] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 650;
}
#logout {
  margin-left: auto;
}
.login {
  margin: 70px auto 20px;
  padding: 26px;
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 14px;
}
.login .form {
  margin-top: 18px;
}
#status {
  color: var(--muted);
  padding: 10px 24px;
  position: relative;
  overflow-wrap: anywhere;
}
#status:empty {
  display: none;
}
#status.error {
  color: var(--error);
}

.mail-workspace {
  min-height: calc(100dvh - 68px);
  display: grid;
  grid-template-columns: 215px minmax(255px, 31%) minmax(0, 1fr);
}
.sidebar,
.message-list,
.reader {
  min-width: 0;
}
.sidebar {
  background: var(--paper);
  padding: 22px 14px;
  border-right: 1px solid var(--line);
}
.account-head,
.folder-header,
.management-head,
.record-head,
.dialog-head,
.message-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.account-head label {
  color: var(--muted);
  font-size: 12px;
}
.account-head button,
.account-actions button {
  background: transparent;
  font-size: 12px;
}
#account,
.write {
  width: 100%;
}
.account-email {
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--ink);
}
#account-status {
  margin: 7px 0;
}
.account-actions {
  display: flex;
  justify-content: space-between;
  gap: 2px;
}
.account-actions button {
  padding-inline: 5px;
}
.write {
  margin: 16px 0;
}
.folders {
  display: grid;
  gap: 3px;
}
.folders button,
.outbox {
  border-color: transparent;
  background: transparent;
  width: 100%;
  text-align: left;
}
.folders button[aria-current] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.outbox {
  margin-top: 16px;
}
.folder-header {
  padding: 20px 16px 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.folder-header .actions {
  gap: 4px;
}
.folder-header button {
  font-size: 12px;
  padding-inline: 8px;
}
.message-list {
  border-right: 1px solid var(--line);
}
.search {
  padding: 0 16px 10px;
  display: flex;
  gap: 5px;
}
.search input {
  flex: 1;
  width: 0;
}
.search button {
  flex-shrink: 0;
}
.list-status {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 16px 10px;
}
.message {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 13px 16px 14px;
  display: grid;
  text-align: left;
  gap: 3px;
  width: 100%;
}
.message[aria-pressed="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 var(--accent);
}
.message-address,
.message-subject,
.message-snippet {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-address {
  color: var(--muted);
  font-size: 12px;
}
.message-time {
  flex-shrink: 0;
}
.message.unread .message-address {
  color: var(--accent);
  font-weight: 650;
}
.message.unread .message-subject {
  font-weight: 650;
}
.message-snippet {
  color: var(--muted);
  font-size: 12px;
}
.page-actions {
  display: flex;
  padding: 12px 16px;
  gap: 8px;
  border-top: 1px solid var(--line);
}
.page-actions:not(:has(button:not([hidden]))) {
  display: none;
}
.reader {
  padding: 26px clamp(18px, 3vw, 44px);
}
.reader h2 {
  font-size: clamp(19px, 2vw, 24px);
  overflow-wrap: anywhere;
}
.reader .small {
  margin-top: 12px;
}
.reader pre {
  margin-top: 23px;
  font-size: 14px;
  line-height: 1.8;
}
.reader .actions {
  margin-top: 15px;
}
.read-actions {
  display: none;
}

.management {
  width: min(920px, 100%);
  padding: 25px clamp(14px, 4vw, 34px);
  margin: 0 auto;
}
.management-section {
  margin-top: 23px;
}
.management-section h2,
.management-section > h3 {
  margin: 0 0 10px;
}
.management-section > h3 {
  margin-top: 20px;
}
.record {
  padding: 15px 17px;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.record .actions {
  margin-top: 12px;
}
.record-head {
  align-items: flex-start;
}
.record h3 {
  overflow-wrap: anywhere;
}
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
}
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 12px;
  font-size: 13px;
  margin: 12px 0;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.preview-text {
  padding: 10px;
  background: var(--paper);
  border-radius: 6px;
}

dialog {
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 15px;
  width: min(470px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
}
dialog.wide {
  width: min(650px, calc(100% - 24px));
}
dialog::backdrop {
  background: #16232778;
}
.dialog-head {
  margin-bottom: 12px;
  gap: 8px;
}
.dialog-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.form {
  display: grid;
  gap: 11px;
}
.form label {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
fieldset {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
fieldset label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding-block: 2px;
}
input[type="checkbox"] {
  accent-color: var(--solid);
}
#key-value {
  font:
    12px ui-monospace,
    monospace;
  width: 100%;
}
#sender,
#wait-account {
  margin-bottom: 10px;
}
#compose-status:empty,
#wait-status:empty,
#key-status:empty,
#connect-status:empty {
  display: none;
}

@media (max-width: 920px) {
  .mail-workspace {
    grid-template-columns: 170px minmax(230px, 34%) minmax(0, 1fr);
  }
  .topbar {
    padding-inline: 15px;
    gap: 15px;
  }
  .sidebar {
    padding-inline: 10px;
  }
  .folder-header {
    padding-inline: 12px;
  }
}
@media (max-width: 690px) {
  .topbar {
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 12px 12px 0;
    min-height: 0;
  }
  #primary-nav {
    order: 3;
    width: 100%;
    gap: 5px;
  }
  #primary-nav button {
    padding-inline: 9px;
  }
  .mail-workspace {
    display: block;
    min-height: 0;
  }
  .sidebar {
    padding-block: 10px 6px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .account-actions,
  .folders {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: flex-start;
  }
  .folders button,
  .outbox,
  .write {
    width: auto;
    font-size: 12px;
  }
  .outbox,
  .write {
    margin-block: 4px;
  }
  .message-list {
    border-right: 0;
  }
  .reader {
    display: none;
  }
  .show-reader .message-list {
    display: none;
  }
  .show-reader .reader {
    display: block;
    padding-top: 6px;
  }
  .read-actions {
    display: flex;
    margin-bottom: 14px;
  }
}
@media (max-width: 375px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
@media (pointer: coarse) {
  button {
    min-height: 42px;
  }
  input,
  textarea,
  select {
    font-size: 16px;
  }
}
