:root {
  --canvas: #f4f6fb;
  --paper: #fff;
  --ink: #202b43;
  --muted: #6e7890;
  --line: #e4e9f3;
  --blue: #365bb3;
  --blue-hover: #294b9b;
  --blue-soft: #e9effc;
  --nav: #202b47;
  --nav-soft: #2e3a5b;
  --danger: #b3444c;
  --radius: 14px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { min-width: 320px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #99b2f6;
  outline-offset: 3px;
}
input, textarea { color: var(--ink); }
a { color: var(--blue); }
[hidden] { display: none !important; }

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 20px;
  color: var(--muted);
}
.boot p { margin: 0; }

.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-symbol {
  display: inline-block;
  position: relative;
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  border-radius: 11px;
  background: var(--blue);
  overflow: hidden;
}
.brand-symbol::before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  top: 7px;
  left: 9px;
  border-radius: 50%;
  background: white;
}
.brand-symbol::after {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  top: 3px;
  left: 16px;
  border-radius: 50%;
  background: var(--blue);
}
.brand-name { font-size: 19px; font-weight: 720; letter-spacing: .02em; }
.brand-name small { font-size: 13px; font-weight: 500; opacity: .72; margin-left: 4px; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 43%) 1fr; background: var(--paper); }
.auth-aside {
  min-height: 100vh;
  padding: clamp(30px, 6vw, 80px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  background: var(--nav);
  overflow: hidden;
  position: relative;
}
.auth-aside .brand-symbol { background: #7b9bf3; }
.auth-aside .brand-symbol::after { background: #7b9bf3; }
.auth-aside-main { position: relative; z-index: 1; }
.auth-aside h1 { margin: 0 0 16px; max-width: 390px; font-weight: 650; font-size: clamp(38px, 4vw, 58px); line-height: 1.16; letter-spacing: -.03em; }
.auth-aside p { margin: 0; max-width: 380px; color: #c0cbe3; line-height: 1.8; }
.auth-aside-bottom { color: #97a7c9; font-size: 12px; position: relative; z-index: 1; }
.auth-mark { position: absolute; right: -82px; bottom: 8%; width: min(32vw, 440px); aspect-ratio: 1; border-radius: 50%; border: 1px solid #536283; opacity: .45; }
.auth-mark::before, .auth-mark::after { content: ""; position: absolute; border: 1px solid #657695; border-radius: 50%; }
.auth-mark::before { inset: 15%; }
.auth-mark::after { inset: 30%; }
.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(100%, 390px); }
.auth-card h2 { margin: 0 0 8px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 30px; color: var(--muted); line-height: 1.65; }
.form { display: grid; gap: 17px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 650; }
.field input, .field textarea, .copy-field input {
  width: 100%;
  border: 1px solid #cfd7e7;
  border-radius: 10px;
  background: white;
  padding: 12px 13px;
  min-height: 46px;
}
.field input::placeholder, .field textarea::placeholder { color: #9ba5b9; }
.field textarea { resize: vertical; min-height: 210px; line-height: 1.7; }
.field-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.error-line { color: var(--danger); background: #fdf0f0; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.55; }
.auth-footnote { margin-top: 25px; color: var(--muted); font-size: 13px; }
.link-button { border: 0; padding: 0; background: none; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
}
.button-primary { background: var(--blue); color: white; }
.button-primary:hover:not(:disabled) { background: var(--blue-hover); }
.button-secondary { background: white; color: var(--ink); border-color: #cfd7e7; }
.button-secondary:hover:not(:disabled) { background: #f7f9fd; }
.button-quiet { background: transparent; color: var(--muted); }
.button-quiet:hover:not(:disabled) { background: #f0f3fa; color: var(--ink); }
.button-danger { background: #fff; color: var(--danger); border-color: #eac0c3; }
.button-wide { width: 100%; }

.mail-shell { height: 100dvh; min-height: 540px; display: grid; grid-template-columns: 228px minmax(300px, 368px) minmax(360px, 1fr); background: var(--paper); }
.sidebar { display: flex; flex-direction: column; gap: 30px; min-width: 0; background: var(--nav); color: white; padding: 27px 16px 18px; }
.sidebar-top { padding: 0 11px; }
.sidebar .brand-symbol { background: #7898ee; }
.sidebar .brand-symbol::after { background: #7898ee; }
.sidebar .brand-name { white-space: nowrap; }
.sidebar .compose-button { margin: 0 8px; min-height: 48px; background: #f6f8fe; color: #213b79; }
.sidebar .compose-button:hover:not(:disabled) { background: white; }
.folder-nav { display: grid; gap: 4px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 9px; padding: 11px 14px; text-align: left; background: transparent; color: #bfcbe4; font-size: 14px; }
.nav-item:hover, .nav-item.active { color: white; background: var(--nav-soft); }
.nav-icon { width: 18px; text-align: center; font-size: 17px; line-height: 1; }
.mobile-logout { display: none; }
.sidebar-spacer { flex: 1; }
.sidebar-account { border-top: 1px solid #3a4868; padding: 17px 9px 2px; min-width: 0; }
.account-address { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe4f7; font-size: 12px; }
.sidebar-account .button { margin-top: 8px; min-height: 32px; padding: 5px 0; color: #aab9d9; }
.sidebar-account .button:hover { color: white; background: transparent; }

.message-list-pane { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fbfcff; }
.pane-header { min-height: 106px; padding: 27px 25px 17px; border-bottom: 1px solid var(--line); }
.pane-header h1 { margin: 0; font-size: 25px; line-height: 1.35; font-weight: 700; letter-spacing: -.03em; }
.pane-header p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.pane-header .quota-warning { color: var(--danger); line-height: 1.5; }
.list-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.load-more { display: flex; justify-content: center; padding: 18px; }
.message-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; display: grid; gap: 7px; padding: 19px 24px 18px; }
.message-row:hover { background: #f2f5fc; }
.message-row.selected { background: var(--blue-soft); box-shadow: inset 3px 0 var(--blue); }
.message-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.message-row-person { font-weight: 650; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.message-row-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.message-row-subject { color: var(--ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row-preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row-flag { font-size: 11px; color: var(--blue); }

.reading-pane { min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: white; }
.reading-top { min-height: 106px; display: flex; align-items: center; gap: 12px; padding: 20px 32px; border-bottom: 1px solid var(--line); }
.reading-top h2 { margin: 0; flex: 1; min-width: 0; font-size: 21px; font-weight: 680; line-height: 1.45; overflow-wrap: anywhere; }
.reading-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.reading-actions .button { min-height: 36px; padding: 6px 10px; font-size: 12px; }
.reading-scroll { overflow-y: auto; flex: 1; padding: 31px clamp(24px, 4vw, 60px) 50px; }
.reading-meta { display: grid; gap: 7px; padding-bottom: 22px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.reading-meta strong { color: var(--ink); font-size: 15px; font-weight: 650; }
.reading-meta .meta-line { display: flex; gap: 9px; overflow-wrap: anywhere; }
.meta-label { flex: 0 0 44px; white-space: nowrap; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.85; margin-top: 25px; max-width: 80ch; }
.raw-mail-note { margin: 26px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.raw-mail-note a { text-underline-offset: 3px; }
.attachments { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 20px; }
.attachments h3 { margin: 0 0 12px; font-size: 13px; }
.attachment-link { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; margin: 0 8px 8px 0; text-decoration: none; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
.attachment-link:hover { background: var(--blue-soft); }
.reading-placeholder, .empty-state, .loading-state { height: 100%; min-height: 180px; display: grid; place-content: center; justify-items: center; text-align: center; padding: 28px; color: var(--muted); }
.reading-placeholder h2, .empty-state h2 { margin: 14px 0 5px; font-size: 17px; color: var(--ink); font-weight: 650; }
.reading-placeholder p, .empty-state p { margin: 0; font-size: 13px; line-height: 1.65; max-width: 290px; }
.empty-icon { width: 45px; height: 34px; border: 2px solid #aabbe2; border-radius: 6px; position: relative; }
.empty-icon::after { content: ""; position: absolute; width: 27px; height: 27px; border-left: 2px solid #aabbe2; border-bottom: 2px solid #aabbe2; transform: rotate(-45deg); left: 7px; top: -13px; }
.mobile-back { display: none; }

.full-pane { grid-column: 2 / -1; min-width: 0; display: flex; flex-direction: column; }
.full-pane .pane-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.full-pane-scroll { overflow-y: auto; flex: 1; padding: 32px clamp(24px, 6vw, 78px) 60px; }
.compose-form { width: min(100%, 800px); display: grid; gap: 19px; }
.compose-form .field { grid-template-columns: 72px minmax(0, 1fr); align-items: start; gap: 15px; }
.compose-form .field label { padding-top: 14px; color: var(--muted); }
.compose-form .field input { border-color: transparent; border-bottom: 1px solid var(--line); border-radius: 0; padding-left: 0; }
.compose-form .field textarea { min-height: 300px; }
.compose-actions { display: flex; justify-content: flex-end; gap: 10px; }
.compose-status { color: var(--muted); font-size: 12px; line-height: 1.6; }
.admin-grid { display: grid; grid-template-columns: minmax(240px, 360px) minmax(280px, 1fr); gap: 35px; max-width: 1000px; }
.admin-help { grid-column: 1 / -1; }
.admin-grid h2 { margin: 0 0 15px; font-size: 18px; }
.admin-grid h2.admin-invite-title { margin-top: 34px; }
.admin-grid .form { gap: 14px; }
.admin-note { font-size: 12px; color: var(--muted); line-height: 1.6; }
.admin-list { display: grid; border-top: 1px solid var(--line); }
.admin-row { display: flex; justify-content: space-between; gap: 15px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.admin-row strong { font-weight: 650; overflow-wrap: anywhere; }
.admin-row small { color: var(--muted); white-space: nowrap; }
.copy-panel { margin-top: 22px; padding: 16px; background: var(--blue-soft); border-radius: var(--radius); }
.copy-panel p { margin: 0 0 10px; font-size: 13px; font-weight: 650; }
.copy-field { display: flex; align-items: center; gap: 8px; }
.copy-field input { font-size: 12px; background: white; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; padding: 12px 16px; border-radius: 10px; color: white; background: var(--nav); box-shadow: 0 14px 35px #1f2b4760; font-size: 13px; max-width: min(360px, calc(100vw - 40px)); }
.toast.error { background: #9e3943; }

@media (max-width: 1080px) {
  .mail-shell { grid-template-columns: 192px minmax(285px, 330px) minmax(320px, 1fr); }
  .sidebar { padding-left: 11px; padding-right: 11px; }
  .reading-scroll { padding-left: 26px; padding-right: 26px; }
}

@media (max-width: 820px) {
  .auth-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-aside { min-height: 112px; height: 112px; padding: 25px; }
  .auth-aside-main, .auth-aside-bottom, .auth-mark { display: none; }
  .auth-main { padding: 34px 24px 60px; place-items: start center; }
  .mail-shell { height: 100dvh; min-height: 520px; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { grid-column: 1; grid-row: 1; display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 16px; }
  .sidebar-top { padding: 0; align-self: center; }
  .sidebar .brand-symbol { width: 33px; height: 33px; flex-basis: 33px; border-radius: 9px; }
  .sidebar .brand-symbol::before { left: 7px; top: 6px; }
  .sidebar .brand-symbol::after { left: 14px; top: 2px; }
  .sidebar .brand-name { font-size: 17px; }
  .sidebar .compose-button { grid-column: 2; grid-row: 1; margin: 0; min-height: 38px; padding: 7px 12px; }
  .folder-nav { grid-column: 1 / -1; grid-row: 2; display: flex; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; padding: 9px 11px; font-size: 12px; }
  .mobile-logout { display: flex; margin-left: auto; }
  .nav-icon { font-size: 14px; width: 14px; }
  .sidebar-spacer, .sidebar-account { display: none; }
  .message-list-pane, .reading-pane, .full-pane { grid-column: 1; grid-row: 2; }
  .reading-pane { display: none; }
  .mail-shell.is-reading .message-list-pane { display: none; }
  .mail-shell.is-reading .reading-pane { display: flex; }
  .mobile-back { display: inline-flex; }
  .reading-top { min-height: 74px; padding: 14px 16px; flex-wrap: wrap; }
  .reading-top h2 { font-size: 17px; }
  .reading-actions { width: 100%; justify-content: flex-end; }
  .reading-scroll { padding: 23px 19px 45px; }
  .pane-header { min-height: 84px; padding: 20px 20px 13px; }
  .pane-header h1 { font-size: 22px; }
  .message-row { padding: 15px 20px; }
  .full-pane-scroll { padding: 24px 20px 50px; }
  .compose-form .field { grid-template-columns: 1fr; gap: 5px; }
  .compose-form .field label { padding: 0; }
  .admin-grid { grid-template-columns: 1fr; gap: 36px; }
}

@media (max-width: 480px) {
  .auth-aside { min-height: 105px; height: 105px; }
  .auth-card h2 { font-size: 25px; }
  .auth-sub { margin-bottom: 23px; }
  .sidebar .brand-name small { display: none; }
  .folder-nav { gap: 2px; }
  .nav-item { gap: 5px; padding-left: 9px; padding-right: 9px; }
  .compose-actions { justify-content: stretch; }
  .compose-actions .button { flex: 1; }
  .copy-field { align-items: stretch; flex-direction: column; }
}

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