:root {
  --paper: #f5efe5;
  --paper-2: #ece3d7;
  --ink: #24231f;
  --muted: #746e65;
  --line: rgba(36, 35, 31, .13);
  --coral: #df7865;
  --coral-dark: #b85343;
  --sage: #9eae92;
  --white: #fffdf9;
  --danger: #a83d35;
  --shadow: 0 28px 80px rgba(69, 49, 33, .14);
  --serif: Georgia, "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--paper); }
body { margin: 0; min-width: 320px; min-height: 100svh; overflow-x: hidden; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #e8b94f; outline-offset: 3px; }
.is-hidden { display: none !important; }
.skip { position: fixed; left: 12px; top: 12px; z-index: 999; padding: 10px 16px; transform: translateY(-150%); background: var(--ink); color: white; border-radius: 999px; }
.skip:focus { transform: translateY(0); }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .045; z-index: 100; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E"); }

.gate { min-height: 100svh; display: grid; place-items: center; padding: 32px 18px; background: radial-gradient(circle at 15% 20%, rgba(223,120,101,.18), transparent 32rem), radial-gradient(circle at 90% 80%, rgba(158,174,146,.2), transparent 28rem), var(--paper); }
.gate-card { width: min(100%, 510px); padding: clamp(28px, 6vw, 58px); background: rgba(255,253,249,.88); border: 1px solid rgba(255,255,255,.9); border-radius: 32px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-card { transform: rotate(-.25deg); }
.wordmark { display: inline-flex; align-items: center; gap: 11px; font-family: var(--serif); font-weight: 700; letter-spacing: -.02em; }
.wordmark > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50% 50% 44% 56%; background: var(--ink); color: var(--white); }
.eyebrow { margin: 44px 0 12px; color: var(--coral-dark); font-size: .72rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.gate h1 { margin: 0; font: 500 clamp(2.7rem, 8vw, 4.8rem)/.98 var(--serif); letter-spacing: -.055em; }
.gate-copy { margin: 22px 0 28px; color: var(--muted); line-height: 1.75; }
.form { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: .84rem; font-weight: 650; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.72); color: var(--ink); padding: 14px 15px; min-height: 50px; transition: border-color .2s, box-shadow .2s, background .2s; }
textarea { resize: vertical; line-height: 1.7; }
input:focus, textarea:focus { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(223,120,101,.12); background: white; outline: 0; }
label small { font-weight: 400; color: var(--muted); }
.button { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer; font-weight: 750; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(36,35,31,.14); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { margin-top: 4px; background: var(--ink); color: white; }
.button.soft { background: var(--paper-2); color: var(--ink); }
.notice { min-height: 1.35em; margin: 16px 0 0; color: var(--danger); font-size: .84rem; }
.privacy-note { margin: 26px 0 0; color: var(--muted); font-size: .74rem; text-align: center; }
.privacy-note span { color: var(--sage); }
.gate-switch { margin: 21px 0 0; text-align: center; color: var(--coral-dark); font-size: .82rem; font-weight: 700; }
.gate-switch a:hover { text-decoration: underline; text-underline-offset: 4px; }
.loader { width: 36px; height: 36px; border: 2px solid rgba(36,35,31,.15); border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
#loading-view { align-content: center; gap: 12px; color: var(--muted); }
.authenticator-card { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 18px; border-radius: 18px; background: var(--paper); }
.authenticator-card .step { width: 40px; height: 40px; display: grid; place-items: center; background: var(--coral); color: white; border-radius: 50%; font: italic 1rem var(--serif); }
.authenticator-card p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.secret-copy { display: grid; gap: 4px; width: 100%; padding: 14px; border: 1px dashed var(--line); border-radius: 14px; background: transparent; cursor: pointer; }
.secret-copy span { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.secret-copy small { color: var(--muted); }
.assigned-address { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 17px; background: rgba(158,174,146,.14); }
.assigned-address small { color: var(--muted); font-size: .7rem; }
.assigned-address strong { overflow-wrap: anywhere; font: 750 .95rem var(--sans); letter-spacing: -.015em; }

.mail-app { min-height: 100svh; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(245,239,229,.86); backdrop-filter: blur(18px); }
.top-actions { display: flex; align-items: center; gap: 13px; }
.account-label { max-width: 150px; overflow: hidden; color: var(--muted); font-size: .76rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.secure-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: rgba(158,174,146,.18); color: #56654d; font-size: .75rem; font-weight: 700; }
.secure-pill i { width: 7px; height: 7px; background: #668259; border-radius: 50%; box-shadow: 0 0 0 4px rgba(102,130,89,.12); }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; transition: background .2s, transform .2s; }
.icon-button:hover { background: var(--white); transform: translateY(-1px); }
.mail-layout { height: calc(100svh - 76px); display: grid; grid-template-columns: 232px minmax(310px, 390px) minmax(380px, 1fr); }
.sidebar { min-width: 0; padding: 26px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.compose-button { min-height: 50px; border: 0; border-radius: 16px; background: var(--coral); color: white; cursor: pointer; font-weight: 750; box-shadow: 0 10px 24px rgba(184,83,67,.18); }
.compose-button span { margin-right: 6px; font-size: 1.2rem; }
.folders { display: grid; gap: 5px; margin-top: 28px; }
.folder { min-height: 48px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 13px; padding: 0 14px; background: transparent; cursor: pointer; color: var(--muted); }
.folder span { display: flex; align-items: center; gap: 12px; }
.folder b { width: 24px; color: var(--ink); font-size: 1.1rem; }
.folder i { min-width: 25px; padding: 3px 7px; border-radius: 999px; background: var(--paper-2); font-style: normal; font-size: .7rem; }
.folder.is-active { background: var(--white); color: var(--ink); box-shadow: 0 8px 24px rgba(55,45,35,.06); }
.address-card { margin-top: auto; padding: 16px; display: grid; grid-template-columns: auto 1fr; gap: 10px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,253,249,.45); }
.address-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--sage); font: 700 1rem var(--serif); }
.address-card small { display: block; color: var(--muted); font-size: .65rem; }
.address-card button { max-width: 130px; padding: 3px 0 0; overflow: hidden; border: 0; background: none; font-size: .72rem; text-overflow: ellipsis; cursor: pointer; }
.back-home { margin: 18px 6px 0; color: var(--muted); font-size: .74rem; }
.invite-button { width: 100%; min-height: 43px; margin-top: 13px; padding-inline: 12px; font-size: .74rem; }

.mail-list-panel { min-width: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(255,253,249,.44); }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 28px 25px 18px; }
.panel-head .eyebrow { margin: 0 0 6px; }
.panel-head h1 { margin: 0; font: 500 2.55rem/1 var(--serif); letter-spacing: -.04em; }
.search-box { margin: 0 20px 15px; height: 45px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.56); }
.search-box svg { width: 18px; color: var(--muted); }
.search-box input { min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.message-list { min-height: 0; overflow-y: auto; padding: 0 12px 24px; scrollbar-width: thin; }
.message-card { width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; padding: 16px 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; transition: background .2s, border-radius .2s; }
.message-card:hover, .message-card.is-active { background: var(--white); border-radius: 15px; border-color: transparent; }
.message-card .avatar { width: 40px; height: 40px; }
.message-card-main { min-width: 0; }
.message-card-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.message-card strong, .message-card h3, .message-card p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-card strong { font-size: .86rem; }
.message-card time { flex: 0 0 auto; color: var(--muted); font-size: .68rem; }
.message-card h3 { margin: 6px 0 3px; font-size: .84rem; font-weight: 650; }
.message-card p { margin: 0; color: var(--muted); font-size: .75rem; }
.message-card.unread::before { content: ""; width: 7px; height: 7px; margin-top: 17px; border-radius: 50%; background: var(--coral); }
.message-card:not(.unread)::before { content: ""; width: 7px; }
.card-meta { display: flex; flex-direction: column; align-items: center; gap: 7px; color: var(--coral-dark); font-size: .78rem; }
.list-empty { padding: 54px 24px; color: var(--muted); text-align: center; }
.list-empty span { display: block; margin-bottom: 10px; font: 2rem var(--serif); color: var(--sage); }

.reader { min-width: 0; overflow-y: auto; background: var(--white); }
.reader.empty { display: grid; place-items: center; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }
.empty-mark { width: 92px; aspect-ratio: 1; display: grid; place-items: center; margin: 0 auto 22px; border-radius: 50% 50% 45% 55%; background: var(--paper); color: var(--coral); transform: rotate(-7deg); }
.empty-mark span { transform: rotate(7deg); font-size: 1.7rem; }
.empty-state h2 { margin: 0 0 8px; color: var(--ink); font: 500 2rem var(--serif); }
.empty-state p { margin: 0; }
.message-detail { min-height: 100%; }
.reader-tools { min-height: 68px; display: flex; align-items: center; gap: 9px; padding: 0 32px; border-bottom: 1px solid var(--line); }
.reader-tools > span { flex: 1; }
.text-button { border: 0; background: none; color: var(--muted); cursor: pointer; }
.mobile-back { display: none; }
.message-header { padding: clamp(28px, 5vw, 60px) clamp(26px, 6vw, 72px) 26px; }
.message-date { margin: 0 0 13px; color: var(--coral-dark); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.message-header h2 { max-width: 780px; margin: 0 0 30px; font: 500 clamp(2rem, 4vw, 4rem)/1.05 var(--serif); letter-spacing: -.045em; overflow-wrap: anywhere; }
.sender-row { display: flex; align-items: center; gap: 12px; }
.avatar { flex: 0 0 auto; width: 45px; height: 45px; display: grid; place-items: center; border-radius: 50%; background: var(--sage); color: var(--ink); font: 700 1rem var(--serif); }
.sender-row div { min-width: 0; }
.sender-row strong, .sender-row small { display: block; overflow-wrap: anywhere; }
.sender-row small { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.message-body { max-width: 850px; padding: 10px clamp(26px, 6vw, 72px) 40px; color: #383630; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { margin: 0 clamp(26px, 6vw, 72px) 36px; padding: 20px; border-radius: 18px; background: var(--paper); }
.attachments h3 { margin: 0 0 12px; font: 500 1.3rem var(--serif); }
.attachment-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.attachment-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-link small { flex: 0 0 auto; color: var(--muted); }
.reader-foot { padding: 0 clamp(26px, 6vw, 72px) 60px; }

.compose-dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100svh - 24px); padding: 0; overflow: hidden; border: 0; border-radius: 28px; background: var(--white); box-shadow: 0 35px 100px rgba(36,35,31,.28); }
.compose-dialog::backdrop { background: rgba(36,35,31,.44); backdrop-filter: blur(7px); }
.compose-card { max-height: calc(100svh - 24px); overflow-y: auto; padding: clamp(24px, 5vw, 42px); display: grid; gap: 16px; }
.compose-card header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 5px; }
.compose-card .eyebrow { margin: 0 0 6px; }
.compose-card h2 { margin: 0; font: 500 2.5rem var(--serif); }
.compose-card footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.compose-card footer > span { color: var(--muted); font-size: .72rem; }
.dialog-copy { margin: 0; color: var(--muted); line-height: 1.7; }
.invite-result { display: grid; gap: 10px; margin-top: 4px; padding: 18px; border-radius: 18px; background: var(--paper); }
.invite-result > small { color: var(--muted); font-size: .7rem; }
.invite-result > strong { overflow-wrap: anywhere; font: 600 1.15rem var(--serif); }
.invite-result textarea { min-height: 84px; resize: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; }
.invite-result p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.6; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; max-width: calc(100% - 32px); padding: 11px 17px; transform: translate(-50%, 20px); border-radius: 999px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; font-size: .82rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 980px) {
  .mail-layout { grid-template-columns: 82px minmax(300px, 360px) minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .compose-button { font-size: 0; }
  .compose-button span { margin: 0; font-size: 1.45rem; }
  .folder { justify-content: center; padding: 0; }
  .folder span { gap: 0; font-size: 0; }
  .folder b { font-size: 1.15rem; }
  .folder i, .address-card div, .back-home { display: none; }
  .address-card { grid-template-columns: 1fr; padding: 11px; }
  .address-icon { margin: auto; }
}

@media (max-width: 720px) {
  .topbar { height: 68px; padding-inline: 15px; }
  .secure-pill { display: none; }
  .account-label { display: none; }
  .mail-layout { height: calc(100svh - 68px); grid-template-columns: 68px minmax(0, 1fr); }
  .mail-list-panel { border-right: 0; }
  .reader { position: fixed; inset: 68px 0 0 68px; z-index: 20; transform: translateX(105%); transition: transform .28s ease; }
  .reader.is-open { transform: translateX(0); }
  .reader.empty { display: none; }
  .mobile-back { display: inline-block; }
  .panel-head { padding: 22px 18px 16px; }
  .search-box { margin-inline: 12px; }
  .message-list { padding-inline: 6px; }
  .sidebar { padding: 16px 8px; }
  .folder { min-height: 46px; }
  .address-card { margin-bottom: 8px; padding: 7px; border: 0; }
  .address-icon { width: 36px; height: 36px; }
  .reader-tools { padding-inline: 18px; }
  .message-header { padding-top: 30px; }
  .compose-card footer { align-items: stretch; flex-direction: column; }
  .compose-card footer .button { width: 100%; }
}

@media (max-width: 420px) {
  .gate { padding: 0; align-items: stretch; }
  .gate-card { min-height: 100svh; border: 0; border-radius: 0; padding: 28px 20px; }
  .login-card { transform: none; }
  .mail-layout { grid-template-columns: 58px minmax(0, 1fr); }
  .reader { left: 58px; }
  .sidebar { padding-inline: 6px; }
  .topbar .wordmark { font-size: .92rem; }
  .topbar .wordmark > span { width: 32px; height: 32px; }
  .message-card { gap: 9px; padding-inline: 9px; }
  .message-card .avatar { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
