:root {
  color-scheme: light;
  --paper: #f4f1ea;
  --paper-deep: #e8e2d7;
  --sheet: #fffefa;
  --ink: #20201d;
  --muted: #77746d;
  --line: #d9d3c7;
  --line-soft: #e9e5dc;
  --red: #b7392f;
  --red-dark: #8e2d26;
  --green: #53715b;
  --navy: #263849;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  --shadow: 0 18px 60px rgb(55 46 35 / 12%);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  overflow: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

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

.login-shell {
  align-items: center;
  background:
    linear-gradient(rgb(255 255 255 / 22%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 22%) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  display: flex;
  min-height: 100vh;
  padding: 40px;
  position: relative;
}

.login-shell::before,
.login-shell::after {
  border: 1px solid rgb(183 57 47 / 20%);
  border-radius: 50%;
  content: "";
  height: 440px;
  left: -180px;
  position: absolute;
  top: -220px;
  width: 440px;
}

.login-shell::after {
  height: 380px;
  inset: auto -190px -210px auto;
  width: 380px;
}

.login-card {
  background: var(--sheet);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  margin: auto;
  max-width: 880px;
  min-height: 540px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.login-card::after {
  border: 1px solid var(--line);
  content: "";
  inset: 9px;
  pointer-events: none;
  position: absolute;
}

.login-story {
  background:
    radial-gradient(circle at 80% 18%, rgb(255 255 255 / 13%) 0 1px, transparent 2px),
    linear-gradient(145deg, #a8342b, #7d2722);
  color: #fff8ea;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: 62px;
  position: relative;
}

.login-story::after {
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 50%;
  content: "";
  height: 340px;
  position: absolute;
  right: -190px;
  top: -90px;
  width: 340px;
}

.login-story .eyebrow { color: #e8c9ad; }

.login-story h1 {
  font-family: var(--serif);
  font-size: clamp(56px, 7vw, 78px);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .9;
  margin: 0 0 28px;
}

.login-intro {
  color: rgb(255 248 234 / 78%);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  margin: 0;
  max-width: 310px;
}

.postmark {
  align-items: center;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 50%;
  display: flex;
  font-size: 10px;
  height: 78px;
  justify-content: center;
  letter-spacing: .18em;
  line-height: 1.5;
  position: absolute;
  right: 42px;
  text-align: center;
  top: 42px;
  transform: rotate(11deg);
  width: 78px;
}

.route-line {
  align-items: center;
  color: rgb(255 255 255 / 55%);
  display: flex;
  font-size: 9px;
  gap: 12px;
  letter-spacing: .16em;
  margin-top: 55px;
}

.route-line i { border-top: 1px dashed rgb(255 255 255 / 40%); flex: 1; }

.login-form-panel {
  align-self: center;
  padding: 64px 58px;
}

.lock-mark {
  align-items: center;
  background: var(--paper);
  border-radius: 50%;
  color: var(--red);
  display: flex;
  height: 46px;
  justify-content: center;
  margin-bottom: 28px;
  width: 46px;
}

.lock-mark svg { height: 21px; width: 21px; }

.login-form-panel h2 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -.03em;
  margin: 0 0 10px;
}

.login-form-panel > p:not(.eyebrow):not(.privacy-note) {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 32px;
}

.login-form-panel label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.password-field { position: relative; }

.password-field input {
  background: #faf8f3;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  padding: 14px 58px 14px 14px;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

.password-field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgb(183 57 47 / 10%);
}

.password-field button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  padding: 10px;
  position: absolute;
  right: 5px;
  top: 5px;
}

.form-error { color: var(--red); font-size: 12px; margin: 9px 0 0; }

.primary-button {
  align-items: center;
  background: var(--red);
  border: 0;
  border-radius: 2px;
  color: white;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  justify-content: space-between;
  margin-top: 18px;
  padding: 14px 16px;
  transition: background .2s, transform .2s;
  width: 100%;
}

.primary-button:hover { background: var(--red-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .7; transform: none; }
.primary-button svg { height: 18px; width: 18px; }

.privacy-note {
  align-items: flex-start;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 9px;
  line-height: 1.45;
  margin: 28px 0 0;
}

.privacy-note svg { color: var(--green); flex: 0 0 auto; height: 16px; width: 16px; }

.app-shell {
  background: var(--sheet);
  display: grid;
  grid-template-columns: 248px minmax(330px, 410px) minmax(420px, 1fr);
  height: 100vh;
  min-height: 560px;
}

.sidebar {
  background:
    linear-gradient(rgb(255 255 255 / 28%) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 34px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px 16px 18px;
  z-index: 20;
}

.brand-row { align-items: center; display: flex; gap: 11px; padding: 0 7px 24px; }

.brand-stamp {
  align-items: center;
  background: var(--red);
  border-radius: 2px;
  color: white;
  display: flex;
  font-family: var(--serif);
  font-size: 20px;
  height: 35px;
  justify-content: center;
  transform: rotate(-2deg);
  width: 35px;
}

.brand-row > div:nth-child(2) { display: flex; flex: 1; flex-direction: column; }
.brand-row strong { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.1; }
.brand-row span { color: var(--muted); font-size: 9px; letter-spacing: .1em; margin-top: 3px; text-transform: uppercase; }

.account-card {
  align-items: center;
  background: rgb(255 254 250 / 65%);
  border: 1px solid var(--line);
  border-radius: 3px;
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  padding: 10px;
}

.account-avatar {
  align-items: center;
  background: var(--navy);
  border-radius: 50%;
  color: white;
  display: flex;
  flex: 0 0 auto;
  font-family: var(--serif);
  font-size: 15px;
  height: 31px;
  justify-content: center;
  width: 31px;
}

.account-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.account-copy strong { font-size: 11px; }
.account-copy span { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { background: #4f8b61; border-radius: 50%; height: 7px; width: 7px; }

.folder-region { display: flex; flex: 1; flex-direction: column; min-height: 0; }

.section-label {
  color: var(--muted);
  display: flex;
  font-size: 9px;
  font-weight: 700;
  justify-content: space-between;
  letter-spacing: .14em;
  padding: 0 9px 8px;
  text-transform: uppercase;
}

.folder-list { overflow-x: hidden; overflow-y: auto; padding-right: 2px; }
.folder-list::-webkit-scrollbar, .message-list::-webkit-scrollbar, .reader-content::-webkit-scrollbar { width: 6px; }
.folder-list::-webkit-scrollbar-thumb, .message-list::-webkit-scrollbar-thumb, .reader-content::-webkit-scrollbar-thumb { background: var(--line); }

.folder-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 10px;
  margin: 1px 0;
  padding: 9px 9px;
  text-align: left;
  transition: background .15s, color .15s;
  width: 100%;
}

.folder-button:hover { background: rgb(255 255 255 / 60%); }
.folder-button.active { background: var(--sheet); box-shadow: 0 1px 8px rgb(55 46 35 / 8%); color: var(--red); font-weight: 700; }
.folder-button svg { flex: 0 0 auto; height: 16px; width: 16px; }
.folder-button .folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.folder-button.active .folder-count { color: var(--red); }

.sidebar-footer { border-top: 1px solid var(--line); padding: 15px 6px 0; }
.readonly-seal { align-items: center; display: flex; gap: 9px; margin-bottom: 9px; }
.readonly-seal svg { color: var(--green); height: 17px; width: 17px; }
.readonly-seal div { display: flex; flex-direction: column; }
.readonly-seal strong { font-size: 10px; }
.readonly-seal span { color: var(--muted); font-size: 8px; }

.text-button {
  align-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 10px;
  gap: 7px;
  padding: 8px 0;
}

.text-button:hover { color: var(--red); }
.text-button svg { height: 14px; width: 14px; }

.mail-list-panel {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.list-header { border-bottom: 1px solid var(--line); padding: 25px 22px 17px; }
.list-title-row { align-items: center; display: flex; gap: 10px; }
.list-title-row > div:nth-child(2) { min-width: 0; }
.list-title-row .eyebrow { margin-bottom: 2px; }
.list-title-row h1 { font-family: var(--serif); font-size: 29px; font-weight: 400; letter-spacing: -.03em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-actions { align-items: center; display: flex; gap: 8px; margin-left: auto; }
.message-total { color: var(--muted); font-size: 10px; white-space: nowrap; }

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  transition: background .15s, border-color .15s, transform .15s;
  width: 32px;
}

.icon-button:hover { background: var(--paper); border-color: #c8c0b3; }
.icon-button:active { transform: rotate(-8deg) scale(.95); }
.icon-button svg { height: 15px; width: 15px; }
.icon-button.loading svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-box {
  align-items: center;
  background: #f8f6f1;
  border: 1px solid var(--line-soft);
  display: flex;
  gap: 9px;
  margin-top: 18px;
  padding: 0 11px;
  transition: border .2s, box-shadow .2s;
}

.search-box:focus-within { border-color: #c9bcb0; box-shadow: 0 2px 12px rgb(55 46 35 / 6%); }
.search-box > svg { color: var(--muted); height: 16px; width: 16px; }
.search-box input { background: transparent; border: 0; min-width: 0; outline: none; padding: 11px 0; width: 100%; }
.search-box input::placeholder { color: #98948c; }
.search-box button { align-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; display: flex; padding: 2px; }
.search-box button svg { height: 14px; width: 14px; }
.search-box .search-submit { padding: 0; }
.search-box kbd { border: 1px solid var(--line); border-radius: 2px; color: var(--muted); font-family: var(--sans); font-size: 9px; padding: 1px 5px; }
.search-help { color: var(--muted); font-size: 9px; margin: 7px 1px 0; }
.search-help code { background: var(--paper); color: #625f58; padding: 1px 2px; }

.message-list { flex: 1; min-height: 0; overflow-y: auto; }

.message-row {
  background: var(--sheet);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  display: block;
  padding: 16px 20px 15px 25px;
  position: relative;
  text-align: left;
  transition: background .15s;
  width: 100%;
}

.message-row:hover { background: #fbf9f4; }
.message-row.active { background: var(--paper); }
.message-row.active::after { background: var(--red); content: ""; inset: 0 auto 0 0; position: absolute; width: 3px; }
.message-row.unread::before { background: var(--red); border-radius: 50%; content: ""; height: 6px; left: 10px; position: absolute; top: 22px; width: 6px; }
.message-meta { align-items: baseline; display: flex; gap: 10px; margin-bottom: 6px; }
.message-sender { flex: 1; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row.unread .message-sender { font-weight: 750; }
.message-date { color: var(--muted); font-size: 9px; white-space: nowrap; }
.message-subject { font-family: var(--serif); font-size: 15px; line-height: 1.35; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-to { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-markers { align-items: center; display: flex; gap: 5px; margin-top: 8px; }
.message-marker { align-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); display: flex; font-size: 8px; gap: 3px; padding: 2px 6px; }
.message-marker svg { height: 9px; width: 9px; }

.list-state { align-items: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; justify-content: center; min-height: 240px; padding: 30px; text-align: center; }
.list-state svg { color: #a29d93; height: 36px; width: 36px; }
.list-state strong { color: var(--ink); font-family: var(--serif); font-size: 19px; font-weight: 400; }
.list-state span { font-size: 11px; line-height: 1.5; max-width: 250px; }

.message-skeleton { border-bottom: 1px solid var(--line-soft); padding: 19px 22px; }
.skeleton-line { animation: shimmer 1.4s infinite linear; background: linear-gradient(90deg, #ece8df 25%, #f7f5f0 50%, #ece8df 75%); background-size: 200% 100%; border-radius: 2px; height: 9px; margin-bottom: 10px; }
.skeleton-line.short { width: 35%; }
.skeleton-line.medium { height: 13px; width: 72%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.pagination { align-items: center; border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding: 11px 17px; }
.pagination span { color: var(--muted); font-size: 9px; }
.pagination-button { align-items: center; background: none; border: 0; cursor: pointer; display: flex; font-size: 10px; gap: 4px; padding: 5px; }
.pagination-button:hover { color: var(--red); }
.pagination-button:disabled { color: #bbb5aa; cursor: default; }
.pagination-button svg { height: 13px; width: 13px; }

.reader-panel { background: var(--sheet); min-width: 0; overflow: hidden; position: relative; }
.empty-reader { align-items: center; display: flex; flex-direction: column; height: 100%; justify-content: center; padding: 50px; text-align: center; }
.empty-envelope { color: #b5aea2; margin-bottom: 28px; position: relative; }
.empty-envelope::after { border: 1px solid rgb(183 57 47 / 25%); border-radius: 50%; content: ""; height: 76px; left: 23px; position: absolute; top: 5px; width: 76px; }
.empty-envelope svg { height: 90px; stroke-width: 1; width: 120px; }
.empty-reader h2 { font-family: var(--serif); font-size: 30px; font-weight: 400; letter-spacing: -.03em; margin: 0 0 10px; }
.empty-reader > p:last-child { color: var(--muted); line-height: 1.6; margin: 0; max-width: 390px; }

.message-reader { display: flex; flex-direction: column; height: 100%; }
.reader-toolbar { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: 66px; padding: 15px 28px; }
.safe-text-badge { align-items: center; color: var(--green); display: flex; font-size: 9px; font-weight: 700; gap: 6px; letter-spacing: .08em; text-transform: uppercase; }
.safe-text-badge svg { height: 15px; width: 15px; }
.reader-content { flex: 1; overflow-y: auto; padding: 42px clamp(32px, 6vw, 76px) 70px; }
.reader-subject { font-family: var(--serif); font-size: clamp(29px, 3vw, 43px); font-weight: 400; letter-spacing: -.035em; line-height: 1.12; margin: 0 0 28px; max-width: 850px; }
.reader-sender-line { align-items: center; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; padding-bottom: 22px; }
.sender-avatar { align-items: center; background: var(--navy); border-radius: 50%; color: white; display: flex; flex: 0 0 auto; font-family: var(--serif); font-size: 17px; height: 42px; justify-content: center; width: 42px; }
.sender-details { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.sender-details strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-details span { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-date { color: var(--muted); font-size: 10px; text-align: right; }
.recipient-details { background: var(--paper); border-left: 2px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.7; margin-top: 16px; padding: 9px 12px; }
.reader-body { color: #302f2b; font-family: var(--serif); font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; padding: 34px 0; white-space: pre-wrap; }
.attachment-region { border-top: 1px solid var(--line-soft); padding-top: 18px; }
.attachment-region h3 { font-size: 9px; letter-spacing: .12em; margin: 0 0 11px; text-transform: uppercase; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { align-items: center; background: var(--paper); border: 1px solid var(--line); display: flex; gap: 8px; max-width: 270px; padding: 9px 11px; }
.attachment-chip svg { color: var(--muted); flex: 0 0 auto; height: 15px; width: 15px; }
.attachment-chip div { display: flex; flex-direction: column; min-width: 0; }
.attachment-chip strong { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip span { color: var(--muted); font-size: 8px; }
.message-id { color: #aaa49a; font-size: 8px; margin-top: 35px; overflow-wrap: anywhere; }

.back-button { align-items: center; background: none; border: 0; cursor: pointer; display: flex; gap: 3px; padding: 5px 5px 5px 0; }
.back-button svg { height: 17px; width: 17px; }
.mobile-only { display: none; }

.toast {
  background: var(--ink);
  border-radius: 2px;
  bottom: 22px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  color: white;
  font-size: 11px;
  left: 50%;
  max-width: calc(100vw - 40px);
  padding: 11px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 100;
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 220px 350px minmax(380px, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .reader-content { padding-left: 38px; padding-right: 38px; }
}

@media (max-width: 820px) {
  body { overflow: hidden; }
  .app-shell { display: block; position: relative; }
  .mobile-only { display: flex; }
  .desktop-only { display: none; }
  .sidebar { box-shadow: 14px 0 45px rgb(32 32 29 / 18%); height: 100%; left: 0; max-width: 300px; position: fixed; top: 0; transform: translateX(-105%); transition: transform .25s ease; width: 82vw; }
  .sidebar.open { transform: translateX(0); }
  .mobile-backdrop { background: rgb(32 32 29 / 35%); inset: 0; position: fixed; z-index: 15; }
  .brand-row #close-sidebar { margin-left: auto; }
  .mail-list-panel { border: 0; height: 100%; }
  .reader-panel { inset: 0; position: fixed; transform: translateX(105%); transition: transform .25s ease; z-index: 10; }
  .reader-panel.open { transform: translateX(0); }
  .reader-toolbar { min-height: 61px; padding: 12px 20px; }
  .reader-content { padding: 30px 24px 60px; }
  .reader-subject { font-size: 31px; }
  .list-header { padding-left: 17px; padding-right: 17px; }
  .message-row { padding-right: 17px; }
  .empty-reader { display: none; }
}

@media (max-width: 680px) {
  .login-shell { padding: 16px; }
  .login-card { display: block; max-width: 430px; min-height: 0; }
  .login-story { min-height: 215px; padding: 34px 34px 30px; }
  .login-story h1 { font-size: 54px; margin-bottom: 13px; }
  .login-intro { font-size: 15px; max-width: 270px; }
  .route-line { display: none; }
  .postmark { height: 62px; right: 30px; top: 27px; width: 62px; }
  .login-form-panel { padding: 36px 34px 40px; }
  .lock-mark { display: none; }
  .login-form-panel h2 { font-size: 30px; }
  .login-form-panel > p:not(.eyebrow):not(.privacy-note) { margin-bottom: 23px; }
  .search-help { display: none; }
  .search-box kbd { display: none; }
  .reader-sender-line { align-items: flex-start; flex-wrap: wrap; }
  .reader-date { margin-left: 54px; text-align: left; width: 100%; }
}

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