/* Domain Mail
   Sorting-room palette: China Post green (邮政绿) on pale paper.
   One bold element: the perforated stamp that holds a verification code. */

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #f1f4f0;
  --surface: #f8faf7;
  --field: #ffffff;
  --sheet: #ffffff;
  --ink: #1b2621;
  --ink-2: #56665e;
  --ink-3: #7e8d85;
  --rule: #d6ded8;
  --hover: #e7ede8;
  --post: #0e6b45;
  --post-hover: #0b5a3a;
  --post-ink: #ffffff;
  --post-tint: #dfede4;
  --post-deep: #0a4d32;
  --danger: #b42318;
  --ring: color-mix(in srgb, var(--post) 24%, transparent);
  --shadow: 0 12px 32px rgba(20, 44, 32, 0.16);
  --font: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1511;
    --surface: #121b16;
    --field: #0b110e;
    --ink: #e3eae5;
    --ink-2: #a0afa6;
    --ink-3: #74837b;
    --rule: #25322b;
    --hover: #1a2620;
    --post: #4db383;
    --post-hover: #66c596;
    --post-ink: #05130c;
    --post-tint: #173020;
    --post-deep: #9be3be;
    --danger: #f28b7d;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2.5px solid var(--post);
  outline-offset: 2px;
}

/* ---------- Perforated stamp edge (shared by the code stamp and the login mark) */

.perforated {
  --r: 5px;
  -webkit-mask:
    radial-gradient(var(--r), #0000 97%, #000) round calc(var(--r) * -1.5) calc(var(--r) * -1.5) /
      calc(var(--r) * 3) calc(var(--r) * 3),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--r) * 3) calc(100% - var(--r) * 3);
  mask:
    radial-gradient(var(--r), #0000 97%, #000) round calc(var(--r) * -1.5) calc(var(--r) * -1.5) /
      calc(var(--r) * 3) calc(var(--r) * 3),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--r) * 3) calc(100% - var(--r) * 3);
}

/* ---------- Controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  border-color: var(--post);
  background: var(--post);
  color: var(--post-ink);
}

.btn.primary:hover:not(:disabled) {
  border-color: var(--post-hover);
  background: var(--post-hover);
}

.btn.quiet {
  border-color: transparent;
  background: none;
  color: var(--ink-2);
}

.btn.quiet:hover {
  background: var(--hover);
  color: var(--ink);
}

.btn.block {
  width: 100%;
  height: 44px;
  font-size: 16px;
}

.btn.danger-quiet {
  border-color: transparent;
  background: none;
  color: var(--ink-2);
}

.btn.danger-quiet:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.icon-btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--field);
}

textarea.input {
  height: auto;
}

.input:focus,
.input:focus-visible {
  outline: none;
  border-color: var(--post);
  box-shadow: 0 0 0 3px var(--ring);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 14px;
}

.field-hint {
  margin: 6px 0 16px;
  color: var(--ink-3);
  font-size: 13px;
}

.form-error {
  min-height: 1.4em;
  margin: 8px 0;
  color: var(--danger);
  font-size: 14px;
}

.form-error:empty {
  min-height: 0;
  margin: 4px 0;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--post);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Login */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.postcard {
  position: relative;
  width: min(420px, 100%);
  padding: 36px 32px 30px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--field);
  box-shadow: var(--shadow);
}

.postcard h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.postcard .lede {
  max-width: 22ch;
  margin: 0 0 28px;
  color: var(--ink-2);
}

.postcard-stamp {
  --r: 3px;
  position: absolute;
  top: 26px;
  right: 26px;
  display: grid;
  place-items: center;
  width: 60px;
  height: 72px;
  background: var(--post);
  color: var(--post-ink);
  transform: rotate(4deg);
}

.postcard-stamp svg {
  width: 30px;
  height: 30px;
  stroke-width: 1.6;
}

.postcard .btn.block {
  margin-top: 6px;
}

/* ---------- App shell */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--post);
  color: var(--post-ink);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.spacer {
  flex: 1;
}

.whoami {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Signed in with a mailbox's own password: no address column, just that mailbox. */
.app.mode-mailbox #pane-addresses {
  display: none;
}

@media (min-width: 960px) {
  .app.mode-mailbox .panes {
    grid-template-columns: 380px minmax(0, 1fr);
  }
}

.panes {
  display: grid;
  grid-template-columns: 300px 380px minmax(0, 1fr);
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--rule);
}

.pane:last-child {
  border-right: 0;
}

#pane-addresses {
  background: var(--surface);
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

#address-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.empty {
  margin: 0;
  padding: 20px 12px;
  color: var(--ink-2);
  font-size: 15px;
}

.empty strong {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.placeholder {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 240px;
  padding: 32px;
  color: var(--ink-3);
  text-align: center;
}

.placeholder p {
  max-width: 30ch;
  margin: 0;
}

/* ---------- Address column */

.create {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--rule);
}

.custom-row {
  display: flex;
  gap: 8px;
}

.custom-row .btn {
  height: 40px;
}

.combo {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  height: 40px;
  padding-left: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--field);
}

.combo:focus-within {
  border-color: var(--post);
  box-shadow: 0 0 0 3px var(--ring);
}

.combo input {
  flex: 1 1 64px;
  width: 0; /* let flex-basis decide; inputs otherwise keep a wide intrinsic size */
  min-width: 48px;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
}

.combo .suffix {
  flex: 0 1 auto;
  min-width: 0;
  padding-right: 12px;
  overflow: hidden;
  color: var(--ink-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.combo select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 62%;
  height: 100%;
  padding: 0 6px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink-2);
}

.filter {
  padding: 12px 14px 4px;
}

.filter .input {
  height: 36px;
}

.addr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'main badge'
    'sub  time';
  gap: 1px 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .addr:hover,
  .msg:hover {
    background: var(--hover);
  }

  .stamp:hover {
    background: color-mix(in srgb, var(--post-tint) 82%, var(--post));
  }

  .chip-code:hover {
    border-style: solid;
    border-color: var(--post);
    background: var(--post);
    color: var(--post-ink);
  }
}

.addr.is-current {
  background: var(--post-tint);
}

.addr-main {
  grid-area: main;
  overflow: hidden;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.addr-domain {
  color: var(--ink-3);
  font-weight: 400;
}

.addr-sub {
  grid-area: sub;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.addr-shared svg {
  width: 14px;
  height: 14px;
  margin: 0 5px -2px 0;
  color: var(--post);
}

.addr-time {
  grid-area: time;
  justify-self: end;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.badge {
  grid-area: badge;
  justify-self: end;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--post);
  color: var(--post-ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pane-foot {
  margin: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Mailbox column */

.pane-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}

.pane-head:empty {
  display: none;
}

.mailbox {
  flex: 1;
  min-width: 0;
}

.mailbox-address {
  margin: 2px 0 0;
  font-size: 21px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.mailbox-address .addr-domain {
  font-weight: 450;
}

.label {
  max-width: 100%;
  margin-top: 2px;
  padding: 2px 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.label.is-empty {
  color: var(--ink-3);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.label-input {
  height: 32px;
  margin-top: 4px;
  font-size: 14px;
}

.mailbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.mailbox-actions .spacer {
  flex: 1;
}

.msg-row {
  position: relative;
}

.msg {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'from    time'
    'subject subject'
    'snippet snippet';
  gap: 1px 10px;
  width: 100%;
  padding: 11px 14px 12px 20px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.msg.has-code {
  padding-right: 104px;
}

.msg.is-open {
  background: var(--post-tint);
}

.msg.is-unread::before {
  content: '';
  position: absolute;
  top: 19px;
  left: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--post);
}

.msg-from {
  grid-area: from;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.msg-time {
  grid-area: time;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.msg-subject {
  grid-area: subject;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.msg-snippet {
  display: -webkit-box;
  grid-area: snippet;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 14px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.msg.is-unread .msg-from,
.msg.is-unread .msg-subject {
  font-weight: 700;
}

.msg-sent {
  color: var(--ink-3);
}

@keyframes arrive {
  from {
    background: var(--post-tint);
  }
}

.msg.is-fresh {
  animation: arrive 2.4s ease-out;
}

.chip-code {
  position: absolute;
  top: 50%;
  right: 14px;
  padding: 3px 8px;
  border: 1px dashed color-mix(in srgb, var(--post) 60%, transparent);
  border-radius: 6px;
  background: var(--post-tint);
  color: var(--post-deep);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  transform: translateY(-50%);
  cursor: pointer;
}

.more-wrap {
  display: flex;
  justify-content: center;
  padding: 4px 0 16px;
}

/* ---------- Reader column */

.reader {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.reader-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 57px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.reader-body {
  width: 100%;
  max-width: 940px;
  padding: 12px 28px 40px;
}

.subject {
  margin: 10px 0 12px;
  font-size: 24px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}

.meta {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.meta-from {
  color: var(--ink);
  font-weight: 650;
}

.stamp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 22px 0 4px;
}

.stamp {
  --r: 6px;
  position: relative;
  padding: 22px 32px;
  border: 0;
  background: var(--post-tint);
  color: var(--post-deep);
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums lining-nums;
  cursor: pointer;
}

.stamp::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.32;
  pointer-events: none;
}

/* The mask clips outlines, so focus shows on the inner frame instead. */
.stamp:focus-visible {
  outline: none;
}

.stamp:focus-visible::before {
  border-width: 3px;
  opacity: 1;
}

.stamp-digits {
  margin-right: -0.14em;
}

.stamp-hint {
  color: var(--ink-2);
  font-size: 14px;
}

.stamp-hint.is-done {
  color: var(--post);
  font-weight: 700;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--hover);
  color: var(--ink-2);
  font-size: 14px;
}

.atts {
  margin-top: 18px;
  font-size: 14px;
}

.atts ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.atts li {
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.atts li span {
  color: var(--ink-3);
}

.atts p {
  margin: 0;
  color: var(--ink-3);
}

.sheet {
  display: block;
  width: 100%;
  min-height: 160px;
  margin-top: 20px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--sheet);
}

/* ---------- Compose */

.compose {
  width: min(580px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.compose::backdrop {
  background: rgba(8, 20, 14, 0.5);
}

.compose form {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.compose header,
.compose footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose header {
  justify-content: space-between;
}

.compose h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
}

.compose label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 14px;
}

.compose .input {
  color: var(--ink);
  font-size: 16px;
}

.compose textarea {
  min-height: 200px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

.compose-from {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.compose-from strong {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.compose footer {
  justify-content: flex-end;
}

.compose-hint {
  margin-right: auto;
  color: var(--ink-3);
  font-size: 13px;
}

/* ---------- Share dialog */

.share-lede,
.share-status {
  margin: 0;
  font-size: 15px;
}

.share-lede strong {
  overflow-wrap: anywhere;
}

.share-status {
  color: var(--ink-2);
  font-size: 14px;
}

.share-row {
  display: flex;
  gap: 8px;
  margin-top: -6px;
}

.share-row .input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.share-row .btn {
  height: 40px;
}

.share-result {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  background: var(--post-tint);
}

.share-result p {
  margin: 0;
  font-size: 14px;
}

.share-result pre {
  margin: 0;
  color: var(--ink);
  font: 600 15px/1.6 var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.share-result .btn {
  justify-self: start;
}

/* ---------- Toast */

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 650;
  box-shadow: var(--shadow);
  opacity: 0;
  overflow-wrap: anywhere;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind='error'] {
  background: var(--danger);
  color: #fff;
}

/* ---------- Responsive */

@media (min-width: 960px) {
  .back {
    display: none;
  }
}

@media (min-width: 960px) and (max-width: 1199px) {
  .panes {
    grid-template-columns: 260px 330px minmax(0, 1fr);
  }
}

@media (max-width: 959px) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
  }

  .pane {
    display: none;
    border-right: 0;
  }

  .app[data-view='addresses'] #pane-addresses,
  .app[data-view='messages'] #pane-messages,
  .app[data-view='reader'] #pane-reader {
    display: flex;
  }

  .pane-head {
    padding: 12px 12px 14px 8px;
  }

  .reader-head {
    padding: 8px 12px 8px 8px;
  }

  .reader-body {
    padding: 8px 16px 32px;
  }

  .subject {
    font-size: 21px;
  }

  .stamp {
    font-size: 38px;
  }

  .compose-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }

  .msg.is-fresh {
    animation: none;
  }
}
