:root {
  color-scheme: light;
  --mail-ink: #17243b;
  --mail-muted: #77849a;
  --mail-blue: #3977ef;
  --mail-blue-pale: #eaf1ff;
  --mail-line: #e9edf4;
  --mail-surface: #fff;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body.mail-body { min-width: 320px; min-height: 100vh; margin: 0; background: #f4f7fc; color: var(--mail-ink); }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.mail-app { min-height: 100vh; }
.mail-topbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 245px minmax(220px, 1fr) 245px; align-items: center; height: 76px; padding: 0 30px; border-bottom: 1px solid var(--mail-line); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.mail-brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; font-family: "Manrope", sans-serif; font-size: 16px; font-weight: 800; letter-spacing: -.03em; }
.mail-brand-mark { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 12px; background: linear-gradient(145deg,#4b8af9,#42c1dd); box-shadow: 0 5px 13px #3977ef30; color: white; }
.mail-brand-light { color: #74839b; font-weight: 600; }
.mail-search { display: flex; align-items: center; gap: 11px; width: min(100%, 620px); height: 44px; margin: auto; padding: 0 13px; border: 1px solid #e7ebf2; border-radius: 14px; background: #f7f9fc; }
.mail-search svg { width: 17px; flex: 0 0 17px; fill: none; stroke: #8491a6; stroke-width: 1.8; }
.mail-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--mail-ink); font-size: 13px; }
.mail-search input::placeholder { color: #9aa5b6; }
.mail-search kbd { padding: 3px 6px; border: 1px solid #e4e8ef; border-radius: 6px; color: #8d98a9; font: 10px "DM Sans",sans-serif; white-space: nowrap; }
.mail-account { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.preview-badge { padding: 6px 9px; border: 1px solid #f4dfb2; border-radius: 7px; background: #fff8e8; color: #9a722a; font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.avatar { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 50%; background: #e6edff; color: #5472ba; font-weight: 700; }
.avatar-you { background: linear-gradient(145deg,#bce8e1,#dfe5ff); color: #39737b; }
.preview-notice { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 30px; border-bottom: 1px solid #f1e6cc; background: #fffaf0; color: #786743; font-size: 11px; }
.preview-notice strong { color: #775a1e; }
.preview-notice a { margin-left: auto; color: #576d92; font-weight: 700; white-space: nowrap; }
.notice-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #d49b31; }
.mail-layout { display: grid; grid-template-columns: 220px minmax(0,1fr); min-height: calc(100vh - 118px); }
.mail-sidebar { position: sticky; top: 118px; display: flex; height: calc(100vh - 118px); min-height: 500px; flex-direction: column; padding: 25px 15px 18px; border-right: 1px solid var(--mail-line); background: #fbfcfe; }
.compose-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; margin: 0 4px 24px; border: 0; border-radius: 13px; background: linear-gradient(110deg,#3977ef,#5d83ed); box-shadow: 0 7px 15px #3977ef30; color: white; cursor: pointer; font-size: 13px; font-weight: 700; }
.compose-button span { font-size: 20px; font-weight: 400; }
.folder-list { display: grid; gap: 4px; }
.folder-button { display: grid; grid-template-columns: 24px minmax(0,1fr) auto; align-items: center; min-height: 41px; padding: 0 11px; border: 0; border-radius: 10px; background: transparent; color: #65738a; cursor: pointer; text-align: left; font-size: 12px; }
.folder-button:hover { background: #f1f4f9; }
.folder-button.is-active { background: var(--mail-blue-pale); color: #3269d4; font-weight: 700; }
.folder-icon { color: #8491a6; font-size: 17px; }
.folder-button.is-active .folder-icon { color: var(--mail-blue); }
.folder-count { color: #5d72a0; font-size: 10px; font-weight: 700; }
.sidebar-bottom { margin-top: auto; }
.storage-card { margin: 10px 5px 22px; padding: 13px 11px; border: 1px solid #edf0f5; border-radius: 12px; background: white; }
.storage-heading { display: flex; justify-content: space-between; color: #65738a; font-size: 10px; font-weight: 700; }
.storage-heading span+span { color: #9aa5b6; font-weight: 500; }
.storage-track { height: 5px; margin: 11px 0 8px; overflow: hidden; border-radius: 5px; background: #edf1f6; }
.storage-track span { display: block; width: 11%; height: 100%; border-radius: inherit; background: #78a0f5; }
.storage-card small { color: #9aa5b6; font-size: 9px; line-height: 1.5; }
.back-home { display: flex; gap: 8px; align-items: center; padding: 10px; color: #78869a; font-size: 11px; font-weight: 600; }
.back-home:hover { color: var(--mail-blue); }
.mail-main { display: grid; min-width: 0; min-height: calc(100vh - 118px); grid-template-columns: minmax(320px, 410px) minmax(0,1fr); }
.message-list-panel { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--mail-line); background: white; }
.list-heading { display: flex; align-items: center; justify-content: space-between; min-height: 91px; padding: 20px 22px 14px; }
.list-overline { margin-bottom: 5px; color: #94a0b2; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.list-heading h1 { margin: 0; font-family: "Manrope",sans-serif; font-size: 22px; letter-spacing: -.04em; }
.icon-button { display: inline-grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #76849a; cursor: pointer; font-size: 17px; }
.icon-button:hover { border-color: #e9edf4; background: #f7f9fc; color: var(--mail-blue); }
.list-toolbar { display: flex; align-items: center; gap: 3px; min-height: 45px; padding: 0 16px; border-top: 1px solid #f0f2f6; border-bottom: 1px solid #f0f2f6; }
.select-all-label { display: grid; width: 31px; place-items: center; }
.select-all-label input, .message-check { accent-color: var(--mail-blue); }
.message-range { margin-left: auto; color: #9aa5b6; font-size: 10px; }
.message-list { overflow-y: auto; }
.message-row { display: grid; grid-template-columns: 19px 29px minmax(0,1fr) 20px; align-items: start; gap: 9px; min-height: 91px; padding: 15px 14px 13px; border-bottom: 1px solid #f0f2f6; cursor: pointer; transition: background 120ms ease; }
.message-row:hover { background: #f8faff; }
.message-row.is-selected { background: #f0f5ff; box-shadow: inset 3px 0 #5585ea; }
.message-row.is-unread { background: #fcfdff; }
.message-check { margin: 5px 0 0; }
.sender-avatar { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: white; font-size: 10px; font-weight: 700; }
.message-copy { min-width: 0; }
.message-topline { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.message-sender { overflow: hidden; color: #57667c; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.message-row.is-unread .message-sender,.message-row.is-unread .message-subject { color: #1c2a42; font-weight: 700; }
.message-time { color: #98a3b3; font-size: 9px; white-space: nowrap; }
.message-subject { overflow: hidden; margin: 6px 0 4px; color: #47566e; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.message-snippet { overflow: hidden; margin: 0; color: #95a0b1; font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.message-star { padding: 0; border: 0; background: transparent; color: #a3adbc; cursor: pointer; font-size: 17px; line-height: 1; }
.message-star.is-starred { color: #e7aa36; }
.empty-state { display: grid; flex: 1; align-content: center; justify-items: center; padding: 30px; color: #8c98aa; text-align: center; }
.empty-state>span { margin-bottom: 10px; color: #a6b7d6; font-size: 34px; }
.empty-state strong { color: #53627a; font-size: 13px; }
.empty-state p { font-size: 11px; }
.reader-panel { min-width: 0; background: #fff; }
.reader-empty { display: flex; height: 100%; min-height: 500px; flex-direction: column; align-items: center; justify-content: center; padding: 30px; color: #96a1b1; text-align: center; }
.reader-empty-icon { display: grid; width: 58px; height: 58px; margin-bottom: 18px; place-items: center; border-radius: 20px; background: #f3f6fc; color: #88a4d8; font-size: 25px; }
.reader-empty strong { color: #57667c; font-family: "Manrope",sans-serif; font-size: 15px; }
.reader-empty p { margin: 7px 0; font-size: 11px; }
.message-reader { min-height: 100%; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 23px; border-bottom: 1px solid #f0f2f6; }
.reader-back { display: none; align-items: center; gap: 7px; padding: 8px 0; border: 0; background: transparent; color: #67768c; cursor: pointer; font-size: 11px; font-weight: 700; }
.reader-actions { display: flex; gap: 3px; margin-left: auto; }
.reader-content { max-width: 800px; margin: 0 auto; padding: 32px clamp(22px,4vw,58px); }
.reader-label { margin-bottom: 9px; color: #8896ac; font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.reader-content h2 { margin: 0 0 23px; color: #26354c; font-family: "Manrope",sans-serif; font-size: clamp(19px,2vw,26px); letter-spacing: -.04em; line-height: 1.3; }
.reader-sender { display: flex; align-items: center; gap: 11px; padding-bottom: 23px; border-bottom: 1px solid #f0f2f6; }
.sender-details { display: grid; gap: 3px; min-width: 0; }
.sender-details strong { color: #4a5970; font-size: 11px; }
.sender-details small { overflow: hidden; color: #9aa5b6; font-size: 10px; text-overflow: ellipsis; }
.reader-sender time { margin-left: auto; color: #9aa5b6; font-size: 9px; white-space: nowrap; }
.reader-body { padding: 23px 0; color: #5b687c; font-size: 12px; line-height: 1.85; white-space: pre-wrap; }
.reply-button { display: inline-flex; align-items: center; gap: 8px; min-height: 37px; padding: 0 14px; border: 1px solid #e6eaf1; border-radius: 11px; background: white; color: #63738b; cursor: pointer; font-size: 11px; font-weight: 600; }
.reply-button:hover { border-color: #cbd8f0; background: #f8faff; color: #396fda; }
.compose-dialog { width: min(550px,calc(100vw - 28px)); max-width: none; max-height: min(680px,calc(100vh - 30px)); padding: 0; overflow: hidden; border: 1px solid #e4e9f1; border-radius: 17px; background: white; box-shadow: 0 24px 80px #15274636; }
.compose-dialog::backdrop { background: #18253b66; backdrop-filter: blur(3px); }
.compose-dialog form { display: flex; min-height: 420px; max-height: inherit; flex-direction: column; }
.compose-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 17px; border-bottom: 1px solid #edf0f5; background: #f9fbfe; }
.compose-header h2 { margin: 0; font-family: "Manrope",sans-serif; font-size: 13px; }
.compose-field { display: flex; align-items: center; gap: 13px; min-height: 45px; padding: 0 18px; border-bottom: 1px solid #f0f2f6; color: #7b879b; font-size: 11px; }
.compose-field input { width: 100%; border: 0; outline: 0; color: var(--mail-ink); font-size: 12px; }
.compose-dialog textarea { width: 100%; flex: 1; min-height: 150px; padding: 17px 18px; resize: vertical; border: 0; outline: 0; color: var(--mail-ink); font-size: 12px; line-height: 1.7; }
.compose-dialog textarea::placeholder { color: #a2acba; }
.compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid #edf0f5; }
.compose-footer>span { color: #9a7a3c; font-size: 9px; }
.send-button { min-height: 36px; padding: 0 13px; border: 0; border-radius: 10px; background: var(--mail-blue); color: white; cursor: pointer; font-size: 10px; font-weight: 700; }
.send-button span { margin-left: 5px; }
.mail-toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: min(390px,calc(100vw - 32px)); padding: 12px 16px; transform: translateY(20px); border: 1px solid #dfe7f3; border-radius: 12px; background: white; box-shadow: 0 10px 35px #15274620; color: #53627a; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity 160ms ease,transform 160ms ease; }
.mail-toast.is-visible { transform: translateY(0); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 980px) {
  .mail-topbar { grid-template-columns: 190px minmax(180px,1fr) 150px; padding: 0 20px; }
  .mail-layout { grid-template-columns: 190px minmax(0,1fr); }
  .mail-main { grid-template-columns: minmax(280px,360px) minmax(0,1fr); }
  .preview-notice { padding-right: 20px; padding-left: 20px; }
}

@media (max-width: 700px) {
  .mail-topbar { grid-template-columns: 1fr auto; height: auto; min-height: 62px; gap: 10px; padding: 10px 14px; }
  .mail-brand { font-size: 14px; }
  .mail-brand-mark { width: 32px; height: 32px; }
  .mail-search { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 40px; }
  .mail-search kbd { display: none; }
  .mail-account { grid-column: 2; grid-row: 1; gap: 8px; }
  .preview-badge { padding: 5px 6px; font-size: 8px; }
  .avatar { width: 32px; height: 32px; flex-basis: 32px; }
  .preview-notice { align-items: flex-start; padding: 9px 13px; font-size: 10px; line-height: 1.45; }
  .preview-notice a { display: none; }
  .mail-layout { display: block; min-height: calc(100vh - 122px); }
  .mail-sidebar { position: sticky; z-index: 4; top: 112px; height: auto; min-height: 0; padding: 9px 10px; border-right: 0; border-bottom: 1px solid var(--mail-line); background: rgba(251,252,254,.96); }
  .compose-button { position: fixed; right: 15px; bottom: 16px; z-index: 7; width: 54px; min-height: 54px; margin: 0; border-radius: 18px; box-shadow: 0 9px 24px #3977ef55; font-size: 0; }
  .compose-button span { font-size: 26px; }
  .folder-list { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
  .folder-list::-webkit-scrollbar { display: none; }
  .folder-button { display: flex; flex: 0 0 auto; gap: 6px; min-height: 36px; padding: 0 11px; border: 1px solid transparent; font-size: 10px; }
  .folder-button:not(.is-active) { background: white; border-color: #edf0f5; }
  .folder-icon { font-size: 14px; }
  .folder-count { margin-left: 1px; }
  .sidebar-bottom { display: none; }
  .mail-main { display: block; min-height: 0; }
  .message-list-panel { min-height: calc(100vh - 178px); border-right: 0; }
  .list-heading { min-height: 72px; padding: 14px 16px 10px; }
  .list-heading h1 { font-size: 20px; }
  .list-toolbar { padding: 0 11px; }
  .message-row { grid-template-columns: 17px 28px minmax(0,1fr) 18px; gap: 8px; min-height: 82px; padding: 13px 11px; }
  .message-sender { font-size: 10px; }
  .message-subject { font-size: 10px; }
  .message-snippet { font-size: 9px; }
  .reader-panel { position: fixed; inset: 0; z-index: 8; display: none; overflow-y: auto; }
  .mail-main.has-open-message .reader-panel { display: block; }
  .mail-main.has-open-message .message-list-panel { display: none; }
  .reader-empty { display: none; }
  .reader-toolbar { position: sticky; top: 0; z-index: 2; min-height: 56px; padding: 0 12px; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
  .reader-back { display: inline-flex; }
  .reader-content { padding: 23px 20px 90px; }
  .reader-content h2 { font-size: 21px; }
  .reader-sender time { font-size: 8px; }
  .reader-body { font-size: 13px; }
  .compose-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 16px; }
  .compose-dialog form { min-height: min(460px,calc(100dvh - 18px)); }
  .compose-footer { align-items: flex-start; flex-direction: column; }
  .send-button { align-self: flex-end; }
}

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