:root {
  --ink: #1d2722;
  --ink-soft: #4e5a52;
  --muted: #7f8982;
  --muted-light: #a3aaa4;
  --paper: #f4f1e8;
  --paper-deep: #eae5d8;
  --surface: #fffdf8;
  --surface-cool: #f8f7f2;
  --forest: #173d2e;
  --forest-deep: #102b20;
  --forest-soft: #2b644d;
  --forest-pale: #e6efe9;
  --brass: #c7a45a;
  --brass-soft: #e5d2a7;
  --line: #e4dfd3;
  --line-strong: #d4cdbd;
  --danger: #a84232;
  --danger-soft: #f8e8e4;
  --shadow-sm: 0 1px 2px rgba(23, 40, 31, .04), 0 8px 24px rgba(23, 40, 31, .04);
  --shadow-md: 0 20px 60px rgba(16, 43, 32, .12);
  --shadow-lg: 0 40px 110px rgba(9, 28, 20, .24);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar-w: 254px;
  --topbar-h: 88px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--forest-soft); }
[hidden] { display: none !important; }
::selection { background: var(--brass-soft); color: var(--forest-deep); }
:focus-visible { outline: 2px solid var(--forest-soft); outline-offset: 3px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.brand-sigil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--forest);
  color: #f7f1e4;
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.brand-sigil.small { width: 34px; height: 34px; border-radius: 11px; font-size: 20px; }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-words strong { font-family: var(--font-serif); font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.brand-words em { margin-top: 4px; font-style: normal; font-size: 8px; font-weight: 700; letter-spacing: .3em; color: var(--muted); }

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #67a27c;
  box-shadow: 0 0 0 3px rgba(103, 162, 124, .12);
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--paper);
  color: var(--muted);
  transition: opacity .5s var(--ease), visibility .5s;
}
.boot-screen.leaving { opacity: 0; visibility: hidden; }
.boot-screen p { margin: 0; font-size: 12px; letter-spacing: .18em; }
.boot-mark {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  border-radius: 19px;
  background: var(--forest);
  color: #f7f1e4;
  font-family: var(--font-serif);
  font-size: 34px;
  animation: boot-breathe 1.8s ease-in-out infinite;
}
@keyframes boot-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }

/* ---------------- Login ---------------- */
.login-view {
  display: grid;
  grid-template-columns: minmax(420px, .92fr) minmax(480px, 1.08fr);
  min-height: 100vh;
  background: var(--surface);
  animation: view-in .55s var(--ease) both;
}
@keyframes view-in { from { opacity: 0; } to { opacity: 1; } }

.login-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 46px 50px 38px;
  color: #f4efe2;
  background:
    radial-gradient(circle at 80% 20%, rgba(199, 164, 90, .16), transparent 34%),
    radial-gradient(circle at 12% 88%, rgba(91, 142, 112, .28), transparent 36%),
    linear-gradient(145deg, #1b4736 0%, #143829 46%, #0d271c 100%);
}
.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 45% 52%, black 0%, transparent 75%);
  pointer-events: none;
}
.art-grain {
  position: absolute;
  inset: 0;
  opacity: .1;
  pointer-events: none;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; }
.login-brand .brand-sigil { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.15); color: #f6eedc; box-shadow: none; }
.login-brand .brand-words strong { color: #f7f2e7; }
.login-brand .brand-words em { color: rgba(244,239,226,.55); }

.art-copy { position: relative; z-index: 1; margin: clamp(80px, 15vh, 170px) 0 0; max-width: 520px; }
.art-copy .eyebrow { color: rgba(244,239,226,.5); }
.art-copy h2 {
  margin: 23px 0 27px;
  font-family: var(--font-serif);
  font-size: clamp(44px, 5vw, 72px);
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: -.035em;
}
.art-copy > p:last-child { margin: 0; color: rgba(244,239,226,.62); font-size: 15px; line-height: 1.9; }
.art-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: auto;
  color: rgba(244,239,226,.38);
  font-size: 9px;
  letter-spacing: .19em;
  text-transform: uppercase;
}
.art-rule { flex: 1; height: 1px; background: rgba(255,255,255,.12); }
.art-orbit { position: absolute; border: 1px solid rgba(244,239,226,.09); border-radius: 50%; pointer-events: none; }
.orbit-one { width: 540px; height: 540px; right: -250px; top: 9%; }
.orbit-two { width: 760px; height: 760px; right: -340px; top: 2%; border-color: rgba(244,239,226,.05); }
.orbit-three { width: 310px; height: 310px; left: -180px; bottom: 6%; border-color: rgba(199,164,90,.12); }

.login-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px clamp(36px, 8vw, 120px) 30px;
  background:
    radial-gradient(circle at 80% 10%, rgba(199,164,90,.06), transparent 32%),
    var(--surface);
}
.login-card { width: 100%; max-width: 430px; margin: auto 0; }
.mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 54px; }
.login-card > .eyebrow { color: var(--forest-soft); }
.login-card h1 {
  margin: 17px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(36px, 4vw, 50px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.login-sub { margin: 0 0 44px; color: var(--muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 21px; }
.field-group { display: flex; flex-direction: column; gap: 9px; }
.field-group label { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.account-lock, .password-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.account-lock { background: var(--surface-cool); }
.account-lock:focus-within, .password-field:focus-within {
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 4px rgba(43,100,77,.08);
}
.account-lock input, .password-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 18px;
  font-size: 15px;
}
.account-lock input { padding-left: 4px; color: var(--ink-soft); font-weight: 500; }
.account-lock input:focus-visible, .password-field input:focus-visible { outline: none; }
.lock-icon { display: grid; place-items: center; width: 44px; color: var(--muted); }
.password-field input { padding-right: 48px; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
  transition: background .18s, color .18s, transform .18s;
}
.icon-button:hover { background: rgba(23,61,46,.065); color: var(--forest); }
.icon-button:active { transform: scale(.95); }
.eye-button { position: absolute; right: 7px; color: var(--muted); }
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 13px;
  border: 1px solid transparent;
  font-weight: 600;
  transition: background .2s, color .2s, border-color .2s, transform .15s, box-shadow .2s;
}
.primary-button { background: var(--forest); color: #fbf7ed; box-shadow: 0 10px 24px rgba(23,61,46,.14); }
.primary-button:hover { background: var(--forest-deep); box-shadow: 0 12px 28px rgba(23,61,46,.2); }
.primary-button:active, .secondary-button:active, .danger-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.secondary-button { border-color: var(--line); background: transparent; color: var(--ink-soft); }
.secondary-button:hover { border-color: var(--line-strong); background: var(--surface-cool); }
.danger-button { background: var(--danger); color: #fff; }
.danger-button:hover { background: #8f3325; }
.login-button { width: 100%; height: 54px; margin-top: 4px; border-radius: 14px; justify-content: space-between; padding: 0 21px 0 24px; }
.login-button.is-loading span { opacity: .7; }
.login-button.is-loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-error {
  margin: -4px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}
.login-note { display: flex; align-items: center; gap: 9px; margin-top: 26px; color: var(--muted); font-size: 11px; }
.login-legal { margin: 55px 0 0; color: var(--muted-light); font-size: 10px; letter-spacing: .08em; }

/* ---------------- App shell ---------------- */
.app-view {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  background: var(--paper);
  animation: view-in .45s var(--ease) both;
}
.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 25px 18px 18px;
  border-right: 1px solid var(--line);
  background: #f2eee4;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.sidebar-brand .brand-words strong { font-size: 19px; }
.sidebar-close { display: none; margin-left: auto; }
.compose-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 50px;
  margin: 32px 0 27px;
  padding: 0 15px;
  border: 1px solid rgba(23,61,46,.08);
  border-radius: 14px;
  background: var(--forest);
  color: #fbf7ed;
  box-shadow: 0 10px 24px rgba(23,61,46,.16);
  font-weight: 600;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.compose-button:hover { background: var(--forest-deep); box-shadow: 0 13px 28px rgba(23,61,46,.22); }
.compose-button:active { transform: translateY(1px); }
.compose-button kbd {
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px;
  color: rgba(255,255,255,.55);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
}
.folder-nav { display: flex; flex-direction: column; gap: 3px; }
.folder-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background .16s, color .16s;
}
.folder-item:hover { background: rgba(255,255,255,.55); color: var(--ink); }
.folder-item.active { background: var(--surface); color: var(--forest); box-shadow: var(--shadow-sm); font-weight: 600; }
.folder-item.active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 2px; border-radius: 4px; background: var(--forest-soft); }
.folder-icon { display: grid; place-items: center; width: 20px; height: 20px; color: var(--muted); }
.folder-item.active .folder-icon { color: var(--forest-soft); }
.folder-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.folder-count { min-width: 19px; padding: 1px 6px; border-radius: 20px; color: var(--muted); font-size: 10px; text-align: center; }
.folder-item.unread .folder-name { color: var(--ink); font-weight: 700; }
.folder-item.unread .folder-count { background: var(--forest); color: #fff; font-weight: 700; }
.sidebar-spacer { flex: 1; min-height: 26px; }
.sidebar-card {
  margin: 0 2px 15px;
  padding: 16px;
  border: 1px solid rgba(23,61,46,.08);
  border-radius: 15px;
  background: linear-gradient(150deg, rgba(255,253,248,.9), rgba(247,242,231,.8));
}
.sidebar-card-label { color: var(--muted-light); font-size: 9px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.sidebar-card strong { display: block; margin-top: 7px; color: var(--forest); font-size: 12px; }
.sidebar-card p { margin: 7px 0 12px; color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.sidebar-card-line { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 3px;
  border-top: 1px solid var(--line);
}
.account-avatar, .topbar-avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--brass-soft);
  color: #5b4924;
  font-family: var(--font-serif);
  font-size: 16px;
}
.account-meta { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.account-meta strong { font-size: 12px; font-weight: 600; }
.account-meta span { overflow: hidden; color: var(--muted); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { width: 32px; height: 32px; color: var(--muted); }

.workspace { display: flex; min-width: 0; min-height: 0; flex-direction: column; }
.mobile-backdrop { display: none; }
.topbar {
  display: flex;
  align-items: center;
  gap: 25px;
  min-height: var(--topbar-h);
  padding: 0 29px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,.84);
  backdrop-filter: blur(14px);
}
.mobile-menu { display: none; }
.folder-heading { min-width: 160px; }
.folder-heading .eyebrow { margin-bottom: 4px; font-size: 8px; }
.folder-heading h1 { margin: 0; font-family: var(--font-serif); font-size: 27px; font-weight: 500; letter-spacing: -.025em; }
.search-form {
  position: relative;
  display: flex;
  align-items: center;
  width: min(440px, 42vw);
  height: 42px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-cool);
  color: var(--muted);
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.search-form:focus-within { border-color: rgba(43,100,77,.42); background: #fff; box-shadow: 0 0 0 4px rgba(43,100,77,.06); }
.search-form > svg { margin-left: 14px; flex: 0 0 auto; }
.search-form input { width: 100%; height: 100%; border: 0; outline: 0; background: transparent; padding: 0 10px; font-size: 12.5px; color: var(--ink); }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-form kbd { margin-right: 12px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted-light); font-family: var(--font-sans); font-size: 9px; background: #fff; }
.search-clear { display: grid; place-items: center; width: 28px; height: 28px; margin-right: 7px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.search-clear:hover { background: var(--paper-deep); }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.topbar-divider { width: 1px; height: 24px; margin: 0 7px; background: var(--line); }
.topbar-avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }

.mail-layout { display: grid; grid-template-columns: minmax(340px, 43%) minmax(0, 1fr); flex: 1; min-height: 0; }
.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; padding: 0 22px; border-bottom: 1px solid rgba(228,223,211,.75); }
.filter-pills { display: flex; gap: 3px; }
.filter-pill { padding: 6px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; }
.filter-pill:hover { color: var(--ink); }
.filter-pill.active { background: var(--forest-pale); color: var(--forest); }
.mail-count { color: var(--muted-light); font-size: 10px; white-space: nowrap; }
.message-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d5cfc1 transparent; }
.message-list::-webkit-scrollbar, .reader-body::-webkit-scrollbar { width: 7px; }
.message-list::-webkit-scrollbar-thumb, .reader-body::-webkit-scrollbar-thumb { background: #d5cfc1; border-radius: 10px; }
.message-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  min-height: 93px;
  padding: 18px 17px 17px 20px;
  border: 0;
  border-bottom: 1px solid rgba(228,223,211,.62);
  background: transparent;
  text-align: left;
  transition: background .16s;
}
.message-row:hover { background: #faf8f2; }
.message-row:focus-visible { outline-offset: -3px; }
.message-row.active { background: #f4f7f2; }
.message-row.active::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 2px; border-radius: 4px; background: var(--forest-soft); }
.message-row.unread { background: #fbfaf4; }
.message-row.unread .row-from, .message-row.unread .row-subject { color: var(--ink); font-weight: 700; }
.row-avatar {
  display: grid;
  place-items: center;
  width: 37px; height: 37px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--forest-pale);
  color: var(--forest-soft);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
}
.row-main { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.row-top { display: flex; align-items: baseline; gap: 10px; }
.row-from { flex: 1; overflow: hidden; color: var(--ink-soft); font-size: 12.5px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.row-date { flex: 0 0 auto; color: var(--muted-light); font-size: 9.5px; letter-spacing: .01em; }
.row-subject { overflow: hidden; color: var(--ink); font-size: 12.5px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.row-snippet { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 10.5px; line-height: 1.55; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.row-side { display: flex; width: 24px; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 6px; }
.row-attachment { color: var(--muted-light); }
.row-attachment:empty { display: none; }
.star-button { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #c7c0b1; }
.star-button:hover { background: var(--paper-deep); color: var(--brass); }
.star-button.active { color: var(--brass); }
.star-button svg { width: 15px; height: 15px; }
.unread-dot { width: 6px; height: 6px; margin: 3px auto 0; border-radius: 50%; background: var(--forest-soft); }
.list-footer { display: flex; justify-content: center; min-height: 58px; padding: 10px 20px 15px; border-top: 1px solid rgba(228,223,211,.55); }
.load-more { height: 34px; padding: 0 18px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 10.5px; }
.load-more:hover { border-color: var(--line-strong); color: var(--ink); }
.list-empty, .list-error, .list-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; padding: 40px; color: var(--muted); text-align: center; }
.list-empty h3, .list-error h3 { margin: 16px 0 6px; color: var(--ink); font-family: var(--font-serif); font-size: 20px; font-weight: 500; }
.list-empty p, .list-error p { margin: 0; max-width: 280px; font-size: 11px; line-height: 1.7; }
.empty-illustration { display: grid; place-items: center; width: 61px; height: 61px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-cool); color: var(--muted-light); }
.skeleton-row { display: flex; gap: 13px; padding: 19px 20px; border-bottom: 1px solid rgba(228,223,211,.62); }
.skeleton-avatar, .skeleton-line { border-radius: 8px; background: linear-gradient(90deg, #f0ece2 25%, #f8f6f0 50%, #f0ece2 75%); background-size: 200% 100%; animation: shimmer 1.6s infinite; }
.skeleton-avatar { width: 37px; height: 37px; border-radius: 12px; }
.skeleton-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 9px; }
.skeleton-line.short { width: 42%; }
.skeleton-line.medium { width: 72%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Reader ---------------- */
.reader-pane { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: var(--surface); }
.reader-empty { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--muted); text-align: center; }
.reader-empty-mark { display: grid; place-items: center; width: 82px; height: 82px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface-cool); color: #b8b1a2; transform: rotate(-4deg); }
.reader-empty h2 { margin: 22px 0 6px; color: var(--ink-soft); font-family: var(--font-serif); font-size: 22px; font-weight: 500; }
.reader-empty p { margin: 0; font-size: 11px; }
.reader-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.reader-toolbar { display: flex; align-items: center; gap: 5px; min-height: 52px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.86); }
.reader-toolbar .icon-button { width: 33px; height: 33px; }
.reader-toolbar .icon-button.active { background: var(--forest-pale); color: var(--forest); }
.reader-toolbar-spacer { flex: 1; }
.reader-back { display: none; }
.reader-header { padding: 31px clamp(25px, 4vw, 49px) 24px; border-bottom: 1px solid var(--line); }
.reader-labels { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.mail-label { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; background: var(--forest-pale); color: var(--forest-soft); font-size: 9px; font-weight: 700; letter-spacing: .06em; }
.mail-label.attachment { background: #f2ecdc; color: #7d632f; }
.reader-subject { margin: 0; font-family: var(--font-serif); font-size: clamp(25px, 3.1vw, 39px); font-weight: 400; line-height: 1.25; letter-spacing: -.025em; overflow-wrap: anywhere; }
.reader-meta { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.reader-avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 13px; background: var(--forest-pale); color: var(--forest-soft); font-family: var(--font-serif); font-size: 15px; font-weight: 600; }
.reader-from { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }
.reader-from strong { overflow: hidden; font-size: 12.5px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.reader-from span { overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.reader-date { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.reader-addresses { margin-top: 16px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.reader-addresses span { color: var(--ink-soft); }
.remote-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px clamp(25px, 4vw, 49px) 0;
  padding: 11px 13px;
  border: 1px solid #e9dfc7;
  border-radius: 10px;
  background: #fbf6ea;
  color: #765f32;
  font-size: 10px;
}
.remote-banner svg { flex: 0 0 auto; }
.remote-banner span { flex: 1; }
.remote-banner button { padding: 5px 9px; border: 1px solid #decfad; border-radius: 7px; background: #fff; color: #675126; font-size: 9.5px; font-weight: 600; white-space: nowrap; }
.reader-body { flex: 1; min-height: 0; overflow: auto; padding: 20px clamp(25px, 4vw, 49px) 29px; background: #fff; }
.email-frame { display: block; width: 100%; min-height: 420px; border: 0; background: #fff; }
.reader-attachments { padding: 16px clamp(25px, 4vw, 49px) 20px; border-top: 1px solid var(--line); background: var(--surface-cool); }
.reader-attachments h3 { margin: 0 0 10px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.attachment-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { display: flex; align-items: center; gap: 9px; max-width: 260px; min-height: 43px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink-soft); text-decoration: none; }
.attachment-chip:hover { border-color: var(--line-strong); background: #fbfaf6; }
.attachment-chip .file-icon { display: grid; place-items: center; width: 27px; height: 30px; border-radius: 6px; background: var(--paper-deep); color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; }
.attachment-chip .file-meta { display: flex; min-width: 0; flex-direction: column; }
.attachment-chip strong { overflow: hidden; font-size: 10.5px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.attachment-chip span { color: var(--muted); font-size: 8.5px; }

/* ---------------- Compose ---------------- */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 25px; }
.compose-backdrop { position: absolute; inset: 0; background: rgba(14, 33, 24, .52); backdrop-filter: blur(5px); animation: fade-in .2s both; }
@keyframes fade-in { from { opacity: 0; } }
.compose-panel {
  position: relative;
  display: flex;
  width: min(820px, 100%);
  max-height: calc(100vh - 50px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-up .35s var(--ease) both;
}
@keyframes modal-up { from { opacity: 0; transform: translateY(22px) scale(.99); } }
.compose-header { display: flex; align-items: center; justify-content: space-between; padding: 23px 27px 15px; }
.compose-header .eyebrow { margin-bottom: 4px; font-size: 8px; }
.compose-header h2 { margin: 0; font-family: var(--font-serif); font-size: 26px; font-weight: 500; }
.compose-form { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.compose-addresses { padding: 0 27px; }
.compose-row { display: flex; align-items: center; min-height: 45px; border-bottom: 1px solid var(--line); }
.compose-row label { width: 62px; flex: 0 0 auto; color: var(--muted); font-size: 10.5px; }
.compose-row input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12.5px; }
.compose-row input:focus-visible { outline: none; }
.compose-row:focus-within { border-color: var(--forest-soft); }
.text-button { padding: 5px 7px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.text-button:hover { background: var(--paper); color: var(--ink-soft); }
.subject-row input { font-size: 14px; font-weight: 500; }
.secondary-address { animation: fade-in .2s both; }
.compose-editor-wrap { display: flex; min-height: 190px; flex: 1; flex-direction: column; margin: 14px 27px 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; min-height: 38px; padding: 0 7px; border-bottom: 1px solid var(--line); background: var(--surface-cool); }
.editor-tool { display: grid; place-items: center; width: 30px; height: 29px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); font-family: var(--font-serif); font-size: 13px; }
.editor-tool:hover { background: var(--paper-deep); color: var(--forest); }
.editor-divider { width: 1px; height: 17px; margin: 0 5px; background: var(--line); }
.editor-spacer { flex: 1; }
.editor-hint { padding-right: 7px; color: var(--muted-light); font-size: 8.5px; }
.compose-editor { flex: 1; min-height: 150px; max-height: 37vh; overflow-y: auto; padding: 17px 18px; outline: 0; color: var(--ink); font-size: 13px; line-height: 1.75; }
.compose-editor:empty::before { content: attr(data-placeholder); color: var(--muted-light); pointer-events: none; }
.compose-editor blockquote { margin: 10px 0; padding-left: 13px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--line); background: #fcfbf7; }
.compose-file { display: flex; align-items: center; gap: 7px; max-width: 230px; padding: 5px 7px 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink-soft); font-size: 9.5px; }
.compose-file > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.compose-file small { color: var(--muted-light); font-size: 8px; }
.compose-file button { display: grid; place-items: center; width: 19px; height: 19px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.compose-file button:hover { background: var(--danger-soft); color: var(--danger); }
.compose-error { margin: 12px 27px 0; }
.compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 27px 22px; }
.compose-from { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.compose-actions { display: flex; gap: 9px; }
.compose-actions .primary-button, .compose-actions .secondary-button { min-height: 44px; border-radius: 11px; font-size: 12px; }

/* ---------------- Confirm + toast ---------------- */
.confirm-backdrop { position: absolute; inset: 0; background: rgba(14, 33, 24, .5); backdrop-filter: blur(4px); }
.confirm-panel { position: relative; width: min(390px, 100%); padding: 28px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); animation: modal-up .28s var(--ease) both; }
.confirm-panel h2 { margin: 0 0 9px; font-family: var(--font-serif); font-size: 24px; font-weight: 500; }
.confirm-panel p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.confirm-actions .secondary-button, .confirm-actions .danger-button { min-height: 41px; border-radius: 10px; font-size: 11.5px; }
.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 300; display: flex; width: min(360px, calc(100vw - 40px)); flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid rgba(23,61,46,.1); border-radius: 12px; background: rgba(255,253,248,.97); color: var(--ink-soft); box-shadow: var(--shadow-md); font-size: 11px; line-height: 1.55; animation: toast-in .3s var(--ease) both; backdrop-filter: blur(12px); }
.toast.leaving { animation: toast-out .22s both; }
.toast-icon { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; border-radius: 7px; background: var(--forest-pale); color: var(--forest); }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast strong { display: block; color: var(--ink); font-size: 11.5px; font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .mail-layout { grid-template-columns: minmax(320px, 45%) minmax(0, 1fr); }
  .login-art { padding: 38px; }
  .art-copy h2 { font-size: 52px; }
  .topbar { gap: 18px; padding: 0 22px; }
}

@media (max-width: 860px) {
  :root { --topbar-h: 76px; }
  body { overflow: hidden; }
  .login-view { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { padding: 36px 26px 24px; background: var(--surface); }
  .login-card { max-width: 420px; }
  .mobile-brand { display: flex; }
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 84vw); transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .mobile-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(10,28,20,.36); opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; }
  .mobile-backdrop.open { opacity: 1; visibility: visible; }
  .mobile-menu { display: grid; }
  .topbar { gap: 12px; padding: 0 16px; }
  .folder-heading { min-width: 0; flex: 1; }
  .folder-heading .eyebrow { display: none; }
  .folder-heading h1 { font-size: 21px; white-space: nowrap; }
  .search-form { width: auto; flex: 1; max-width: 260px; }
  .search-form kbd { display: none; }
  .topbar-actions .topbar-divider, .topbar-avatar { display: none; }
  .mail-layout { grid-template-columns: 1fr; position: relative; }
  .list-pane { border-right: 0; }
  .reader-pane { position: fixed; inset: var(--topbar-h) 0 0; z-index: 25; background: var(--surface); transform: translateX(102%); transition: transform .28s var(--ease); }
  .mail-layout.has-reader .reader-pane { transform: translateX(0); }
  .reader-back { display: grid; }
  .reader-toolbar { padding: 0 13px; }
  .reader-header { padding: 23px 19px 18px; }
  .reader-subject { font-size: 26px; }
  .reader-body { padding: 16px 17px 24px; }
  .remote-banner { margin: 14px 17px 0; }
  .reader-attachments { padding: 14px 17px 18px; }
  .compose-panel { width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .modal-layer { padding: 0; }
  .compose-header, .compose-addresses, .compose-footer { padding-left: 18px; padding-right: 18px; }
  .compose-editor-wrap { margin-left: 18px; margin-right: 18px; }
  .compose-error { margin-left: 18px; margin-right: 18px; }
  .compose-editor { max-height: none; }
  .login-card h1 { font-size: 37px; }
}

@media (max-width: 560px) {
  .login-panel { justify-content: flex-start; padding-top: 34px; }
  .mobile-brand { margin-bottom: 60px; }
  .login-card h1 { font-size: 34px; margin-top: 13px; }
  .login-sub { margin-bottom: 32px; }
  .login-legal { margin-top: 38px; }
  .topbar { flex-wrap: wrap; min-height: 118px; align-content: center; gap: 8px 11px; padding-top: 14px; padding-bottom: 12px; }
  .folder-heading { flex: 1; }
  .topbar-actions { order: 2; }
  .search-form { order: 3; width: 100%; max-width: none; flex-basis: 100%; height: 38px; margin-left: 0; }
  :root { --topbar-h: 118px; }
  .list-toolbar { padding: 0 15px; }
  .message-row { padding: 15px 13px 15px 15px; min-height: 86px; }
  .row-avatar { width: 34px; height: 34px; }
  .reader-date { display: none; }
  .compose-actions { width: 100%; }
  .compose-actions button { flex: 1; }
  .compose-footer { flex-direction: column-reverse; align-items: stretch; gap: 12px; padding-bottom: 16px; }
  .compose-from { justify-content: center; }
  .compose-header h2 { font-size: 22px; }
  .attachment-list { max-height: 88px; overflow-y: auto; }
  .toast-region { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

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