/* Envelope reveal and left-to-right lanes inspired by daily.yybb.us/comment/. */
body:has(.letter-wall) {
  --letter-ink: #202022;
  --letter-muted: #77777c;
  --letter-line: #dedee0;
  --letter-paper: #fff;
  --letter-page: #fafafa;
  background: var(--letter-page);
}
html.dark body:has(.letter-wall) {
  --letter-ink: #f1f1f2;
  --letter-muted: #a3a3a8;
  --letter-line: #353538;
  --letter-paper: #222224;
  --letter-page: #171719;
}
body:has(.letter-wall) #main-grid { max-width: 1440px; }
body:has(.letter-wall) #content-wrapper { overflow: visible; }
.letter-wall { color: var(--letter-ink); letter-spacing: 0; }
.letter-wall button { cursor: pointer; }
.letter-wall button:focus-visible { outline: 2px solid var(--letter-ink); outline-offset: 5px; }
.letter-wall__header { display: flex; align-items: end; justify-content: space-between; gap: 24px; max-width: 1160px; margin: 32px auto 0; padding: 0 12px 22px; border-bottom: 1px solid var(--letter-line); }
.letter-wall__eyebrow { margin: 0 0 9px; font: 11px/1.6 ui-monospace, Consolas, monospace; color: var(--letter-muted); }
.letter-wall h1 { margin: 0; font-size: 38px; line-height: 1.2; font-weight: 800; }
.letter-wall__intro { margin: 10px 0 0; font-size: 14px; line-height: 1.8; color: var(--letter-muted); }
.letter-wall__tools { display: flex; align-items: center; gap: 9px; padding-bottom: 5px; flex-shrink: 0; }
.letter-wall__count { font: 12px/1.5 ui-monospace, Consolas, monospace; color: var(--letter-muted); margin-right: 8px; }
.letter-icon-button { display: grid; place-items: center; width: 36px; height: 36px; background: transparent; color: var(--letter-ink); border: 1px solid var(--letter-line); border-radius: 50%; transition: background .2s; }
.letter-icon-button:hover { background: var(--letter-line); }
.letter-icon-button svg { width: 16px; height: 16px; }
.letter-icon-button svg[hidden] { display: none; }
.letter-stage { position: relative; isolation: isolate; margin: 20px calc(50% - 50vw + 9px) 0; overflow-x: clip; }
.letter-stage__aside { position: absolute; top: 66px; left: max(32px, calc((100% - 1120px) / 2)); z-index: 2; color: var(--letter-muted); font: 10px/2 ui-monospace, Consolas, monospace; writing-mode: vertical-rl; }
.letter-stage__aside--right { left: auto; right: max(32px, calc((100% - 1120px) / 2)); }
.letter-envelope { position: relative; width: 530px; max-width: 100%; height: 447px; top: 0; margin-inline: auto; overflow: hidden; z-index: 3; transition: all 1s ease-in-out .3s; }
.is-open .letter-envelope { height: 1050px; top: -200px; }
.letter-envelope__back { position: absolute; bottom: 126px; left: 0; right: 0; height: 317px; background: linear-gradient(155deg, #5d5d60, #29292c 70%); clip-path: polygon(0 55%, 50% 0, 100% 55%, 100% 100%, 0 100%); }
.letter-paper-wrap { position: relative; overflow: visible; width: 500px; max-width: calc(100% - 30px); margin-inline: auto; padding-top: 200px; transition: all 1s ease-in-out .3s; z-index: 10; }
.letter-paper { position: relative; width: 95%; margin: 0 auto; background: var(--letter-paper); border: 1px solid var(--letter-line); border-radius: 5px; overflow: hidden; box-shadow: 0 0 20px #0003; }
.letter-paper__image { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: center 22%; display: block; background: white; }
.letter-paper__body { position: relative; padding: 19px 25px 27px; text-align: center; background: var(--letter-paper); }
.letter-paper__from { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 13px; font: 10px/1.5 ui-monospace, Consolas, monospace; color: var(--letter-muted); }
.letter-paper__from::before,.letter-paper__from::after { content: ''; width: 30px; height: 1px; background: var(--letter-line); }
.letter-paper h2 { font-size: 22px; line-height: 1.5; margin: 0 0 8px; font-weight: 700; }
.letter-paper__text { font: 14px/1.9 system-ui, 'Microsoft YaHei', sans-serif; color: var(--letter-muted); margin: 0; }
.letter-paper__signature { margin: 12px 0 0; font: italic 18px/1.5 Georgia, serif; }
.letter-envelope__front { position: absolute; bottom: -2px; left: 0; width: 100%; height: 259px; pointer-events: none; z-index: 100; }
.letter-envelope__left,.letter-envelope__right,.letter-envelope__bottom { position: absolute; inset: 0; }
.letter-envelope__left { background: linear-gradient(120deg, #464649, #303033); clip-path: polygon(0 0, 57% 73%, 0 100%); }
.letter-envelope__right { background: linear-gradient(230deg, #555558, #343437); clip-path: polygon(100% 0, 43% 73%, 100% 100%); }
.letter-envelope__bottom { background: linear-gradient(172deg, #4b4b4e, #2c2c2f); clip-path: polygon(0 100%, 43% 41%, 57% 41%, 100% 100%); }
.letter-envelope__seal { position: absolute; left: calc(50% - 26px); bottom: 24px; width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid #747477; border-radius: 50%; background: #29292c; color: #eee; font: italic 16px Georgia, serif; box-shadow: inset 0 0 0 4px #353538, 0 3px 6px #0003; }
.letter-envelope__address { position: absolute; bottom: 9px; left: 20px; margin: 0; font: 9px/1.5 ui-monospace, Consolas, monospace; color: #d4d4d7; }
.letter-envelope__opener { position: absolute; inset: auto 0 0; height: 259px; border: 0; background: transparent; z-index: 101; }
.letter-envelope__opener:focus-visible { outline-offset: -6px !important; outline-color: #ccc !important; }
.letter-actions { position: relative; z-index: 6; display: flex; align-items: center; justify-content: center; gap: 12px; margin: 24px 0 48px; transition: margin-top 1s ease-in-out .3s; }
.letter-stage.is-open + .letter-actions { margin-top: -174px; }
.letter-button { border: 1px solid var(--letter-line); border-radius: 5px; background: var(--letter-paper); color: var(--letter-ink); padding: 11px 19px; min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-size: 13px; font-weight: 600; line-height: 1.5; transition: transform .2s, background .2s; }
.letter-button svg { width: 16px; height: 16px; flex-shrink: 0; }
.letter-button:hover { transform: translateY(-2px); }
.letter-button--primary { background: var(--letter-ink); border-color: var(--letter-ink); color: var(--letter-paper); }
.letter-stream { position: fixed; left: 0; right: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.letter-stream__lane { position: absolute; height: 32px; width: 100%; left: 0; }
.letter-stream__item { position: absolute; top: 0; left: 0; display: inline-flex; align-items: center; gap: 7px; max-width: 390px; height: 30px; padding: 3px 12px 3px 4px; border: 1px solid var(--letter-line); border-radius: 999px; background: var(--letter-paper); color: var(--letter-muted); box-shadow: 0 2px 5px #00000004; white-space: nowrap; font: 11px/22px system-ui, 'Microsoft YaHei', sans-serif; will-change: transform; pointer-events: auto; }
.letter-stream__item span:last-child { overflow: hidden; text-overflow: ellipsis; }
.letter-avatar { position: relative; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; flex: none; background: var(--letter-ink); color: var(--letter-paper); font: 9px/1 ui-monospace, Consolas, monospace; overflow: hidden; }
.letter-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); }
.letter-inbox { max-width: 1000px; margin: 0 auto; padding: 28px 0 10px; border-top: 1px solid var(--letter-line); }
.letter-inbox__header { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 20px; }
.letter-inbox h2 { font-size: 21px; line-height: 1.5; margin: 0; }
.letter-inbox__subtitle { margin: 4px 0 0; font-size: 12px; color: var(--letter-muted); }
.letter-inbox__link { background: none; border: 0; color: var(--letter-muted); font-size: 12px; display: flex; gap: 5px; align-items: center; }
.letter-inbox__link svg { width: 14px; height: 14px; }
.letter-messages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.letter-message { display: block; width: 100%; text-align: left; color: var(--letter-ink); background: var(--letter-paper); border: 1px solid var(--letter-line); border-radius: 5px; padding: 20px; transition: border-color .2s, transform .2s; }
.letter-message:hover { border-color: var(--letter-ink); transform: translateY(-3px); }
.letter-message__meta { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.letter-message__meta time { margin-left: auto; color: var(--letter-muted); font: 10px/1.5 system-ui, sans-serif; }
.letter-message__text { font: 14px/1.9 system-ui, 'Microsoft YaHei', sans-serif; overflow-wrap: anywhere; white-space: pre-wrap; margin: 15px 0 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.letter-empty { grid-column: 1 / -1; display: flex; align-items: center; gap: 23px; padding: 29px 0 32px; color: var(--letter-muted); }
.letter-empty__mark { display: grid; place-items: center; width: 52px; height: 64px; flex: none; border: 1px dashed var(--letter-line); border-radius: 3px; font: italic 16px Georgia, serif; transform: rotate(-8deg); }
.letter-empty strong { color: var(--letter-ink); font-size: 16px; font-weight: 500; }
.letter-empty p { margin: 7px 0 0; font: 13px/1.7 system-ui, 'Microsoft YaHei', sans-serif; }
.letter-data-source { display: none; }
body:has(.letter-wall) :is(.gb-compose-panel,.gb-detail-panel,.gb-list-panel) { max-width: min(640px, calc(100vw - 32px)); border-radius: 7px; }
body:has(.letter-wall) .gb-compose-panel { --primary: var(--letter-ink); }
.letter-dialogs :is(.btn-close,.btn-close-detail) { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 1px solid var(--letter-line); border-radius: 5px; background: var(--letter-paper); color: var(--letter-ink); }
.letter-dialogs :is(.btn-close,.btn-close-detail) svg { width: 18px; height: 18px; }
@media (max-width: 900px) {
  .letter-wall__header { margin-top: 23px; }
  .letter-wall h1 { font-size: 32px; }
  .letter-stream__item { max-width: 265px; }
  .letter-stage__aside { left: 15px; }
  .letter-stage__aside--right { left: auto; right: 15px; }
}
@media (max-width: 600px) {
  .letter-wall__header { padding: 0 0 20px; gap: 10px; align-items: start; }
  .letter-wall h1 { font-size: 29px; }
  .letter-wall__intro { max-width: 24em; font-size: 12px; }
  .letter-wall__tools { gap: 5px; }
  .letter-wall__count { display: none; }
  .letter-icon-button { width: 32px; height: 32px; }
  .letter-stage,.letter-stage.is-open { height: auto; margin: 26px 0 20px; overflow: visible; }
  .letter-envelope,.is-open .letter-envelope { top: 0; width: min(100%, 400px); height: auto; overflow: visible; margin: 0 auto; transition: none; }
  .letter-paper-wrap { width: 100%; max-width: none; padding-top: 0; }
  .letter-paper-wrap,.letter-actions { transition: none; }
  .letter-paper { position: relative; width: 100%; min-height: 0; top: auto; left: auto; transform: none; }
  .letter-paper__image { height: auto; aspect-ratio: 1; }
  .letter-paper__body { padding: 20px 18px 25px; }
  .letter-paper h2 { font-size: 20px; }
  .letter-stage__aside,.letter-stream,.letter-envelope__back,.letter-envelope__front,.letter-envelope__opener,[data-letter-motion],[data-letter-replay] { display: none; }
  .letter-actions,.letter-stage.is-open + .letter-actions { margin: 0 0 32px; gap: 9px; }
  .letter-button { padding: 10px 15px; }
  .letter-inbox { padding-top: 22px; }
  .letter-messages { grid-template-columns: 1fr; }
  .letter-empty { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .letter-envelope,.letter-paper-wrap,.letter-actions,.letter-button,.letter-message { transition: none; }
  .letter-stream { display: none; }
  [data-letter-motion] { display: none; }
}
