:root {
  color-scheme: light;
  --paper: #f5f4ee;
  --surface: #fffefa;
  --ink: #192924;
  --muted: #59675f;
  --border: #dedfd5;
  --green: #194d3d;
  --green-dark: #15352b;
  --selected: #e9f0e8;
  --ring: #246852;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 var(--body); }
a { color: var(--green); text-underline-offset: 0.18em; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
h1, h2, p { margin: 0; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  height: 4.625rem; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: .6875rem; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -.02em; min-height: 44px; }
.brand-icon {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .55rem;
  background: var(--green); color: #fff;
}
.brand-icon span, .large-envelope span, .empty-envelope span {
  position: relative; display: block; width: 1.04rem; height: .76rem;
  border: 1px solid currentColor; border-radius: .13rem;
}
.brand-icon span::after, .large-envelope span::after, .empty-envelope span::after {
  content: ""; position: absolute; width: 59%; aspect-ratio: 1;
  border-bottom: 1px solid currentColor; border-right: 1px solid currentColor;
  top: -28%; left: 20%; transform: rotate(45deg);
}
.top-actions { display: flex; align-items: center; gap: .875rem; }
.demo-tag { padding: .1875rem .625rem; border-radius: 100px; background: #ece9d9; color: #605629; font-size: .875rem; }
.quiet { border: 1px solid var(--border); border-radius: .5rem; color: var(--green); background: var(--surface); padding: .5rem .875rem; min-height: 44px; }
.quiet:hover { background: var(--selected); }

.login-main { min-height: calc(100svh - 4.625rem); display: grid; align-items: center; justify-items: center; padding: clamp(1.25rem, 5vw, 4rem); }
.login-card {
  display: grid; grid-template-columns: 1.38fr 1fr; width: min(100%, 56rem); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 1.25rem;
}
.login-form { padding: clamp(1.5rem, 5vw, 3.75rem); }
.login-form h1, .folder h1, .letter h2, .reader-empty h2, .status h1 {
  font-family: var(--display); font-weight: 500; letter-spacing: -.042em; line-height: 1.08;
}
.login-form h1 { font-size: clamp(2.3rem, 4vw, 3.5rem); }
.login-intro { max-width: 28ch; color: var(--muted); margin: .875rem 0 2rem; }
.login-form label { display: block; margin: 1rem 0 .375rem; font-size: .9375rem; font-weight: 650; }
.login-form input, .search input {
  width: 100%; padding: .625rem .875rem; min-height: 46px; border: 1px solid #bbc3b8;
  background: var(--surface); border-radius: .5rem; color: var(--ink);
}
.primary { width: 100%; min-height: 48px; margin-top: 1.375rem; border: 0; border-radius: .5rem; background: var(--green); color: white; font-weight: 700; }
.primary:hover { background: var(--green-dark); }
.form-error { color: #8a2929; background: #f8eae6; border-radius: .5rem; padding: .625rem .75rem; font-size: .9375rem; }
.login-aside { background: var(--green-dark); color: #f4f0df; padding: clamp(1.5rem, 4.25vw, 3rem); align-content: center; }
.login-aside > p { font: 500 clamp(1.6rem, 3vw, 2.5rem)/1.16 var(--display); letter-spacing: -.03em; margin-top: 1.5rem; }
.large-envelope { display: grid; place-items: center; width: 5rem; height: 5rem; border-radius: 50%; background: #305849; color: #f3e9c3; }
.large-envelope span, .empty-envelope span { width: 2.2rem; height: 1.55rem; border-radius: .22rem; }
.demo-credentials { margin-top: 2rem; border-top: 1px solid #537468; padding-top: .875rem; font-size: .875rem; }
.demo-credentials strong { display: block; margin-bottom: .5rem; }
.demo-credentials div { display: flex; gap: .75rem; flex-wrap: wrap; color: #e1e9db; }
.demo-credentials div + div { margin-top: .25rem; }
.demo-credentials code { font-size: .875rem; color: #fff; }

.workspace {
  display: grid; grid-template-columns: minmax(18rem, 23rem) minmax(0, 1fr);
  max-width: 87rem; margin: clamp(0rem, 3.5vw, 3rem) auto;
  width: calc(100% - clamp(0rem, 7vw, 6rem));
  min-height: min(44rem, calc(100svh - 7.625rem));
  border: 1px solid var(--border); border-radius: 1rem; overflow: hidden;
}
.folder { background: var(--surface); min-width: 0; }
.folder-head { padding: 1.5rem 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.folder h1 { font-size: clamp(2rem, 3.5vw, 2.75rem); margin-bottom: 1.125rem; }
.search { display: flex; position: relative; }
.search input { padding-right: 3rem; font-size: .9375rem; }
.search-button {
  position: absolute; right: 1px; top: 1px; height: calc(100% - 2px); width: 44px;
  display: grid; place-items: center; border: 0; border-radius: .4375rem; background: transparent; color: var(--green);
}
.search-button:hover { background: var(--selected); }
.search-button span { position: relative; width: .825rem; height: .825rem; border-radius: 100%; border: 1.5px solid currentColor; }
.search-button span::after { content: ""; position: absolute; right: -.33rem; bottom: -.19rem; width: .37rem; height: 1.5px; background: currentColor; transform: rotate(45deg); }
.reset-search { display: inline-flex; align-items: center; min-height: 44px; font-size: .875rem; background: none; padding: 0; border: 0; color: var(--green); text-decoration: underline; text-underline-offset: .18em; }
.mail-row {
  display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: .75rem; align-items: start;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); color: var(--ink); text-decoration: none;
}
.mail-row:hover { background: #f1f4ed; }
.mail-row.selected { background: var(--selected); box-shadow: inset 3px 0 var(--green); }
.mail-row:focus-visible { outline-offset: -4px; }
.sender-mark {
  width: 2.25rem; height: 2.25rem; display: grid; place-items: center;
  border-radius: .625rem; font-size: .9375rem; font-weight: 750; flex: 0 0 auto;
}
.tone-0 { background: #e4ead7; color: #3b542b; }
.tone-1 { background: #f0e0d0; color: #714426; }
.tone-2 { background: #e8e3ef; color: #584272; }
.row-text { display: grid; gap: .1rem; }
.row-meta { display: flex; align-items: baseline; gap: .5rem; justify-content: space-between; color: var(--muted); font-size: .875rem; }
.row-meta time { flex-shrink: 0; text-align: right; }
.sender, .preview, .row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender { color: var(--green); font-weight: 650; }
.row-text strong { font-size: .975rem; }
.preview { font-size: .875rem; color: var(--muted); }
.folder-empty { padding: 1rem 1.25rem; color: var(--muted); }
.pagination { display: flex; gap: 1.25rem; padding: .5rem 1.25rem; flex-wrap: wrap; }
.pagination a, .back { display: inline-flex; align-items: center; min-height: 44px; }

.reader { background: #fbfaf5; min-width: 0; border-left: 1px solid var(--border); display: grid; }
.reader-empty { align-self: center; justify-self: center; text-align: center; padding: 2rem 1.25rem; }
.empty-envelope { display: grid; place-items: center; width: 4.75rem; height: 4.75rem; border-radius: 1rem; color: var(--green); background: var(--selected); margin: 0 auto 1.25rem; }
.reader-empty h2 { font-size: clamp(1.85rem, 3vw, 2.6rem); }
.reader-empty p { color: var(--muted); margin-top: .5rem; }
.letter { padding: clamp(1.25rem, 4.25vw, 3.5rem); overflow-wrap: anywhere; }
.letter-head { border-bottom: 1px solid var(--border); padding-bottom: 1.375rem; }
.letter-label { font-size: .875rem; color: var(--muted); margin-bottom: .5rem; }
.letter h2 { font-size: clamp(2rem, 4.8vw, 3.375rem); }
.letter-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-top: 1.375rem; }
.letter-sender { display: flex; align-items: center; gap: .625rem; min-width: 0; }
.letter-sender strong, .letter-sender div span { display: block; }
.letter-sender div span, .letter-meta time { color: var(--muted); font-size: .875rem; }
.letter-body { margin-top: 1.5rem; max-width: 72ch; white-space: pre-wrap; line-height: 1.7; }
.attachment-note { margin-top: 1.5rem; color: var(--muted); font-size: .9375rem; }
.back { display: none; }
.status { width: min(100% - 2rem, 40rem); margin: 7vh auto; }
.status h1 { font-size: 2.5rem; }
.status p { margin: 1rem 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .topbar { height: 4rem; }
  .workspace { display: block; width: 100%; margin: 0; border: 0; border-radius: 0; }
  .reader { border: 0; }
  .inbox-page .workspace:not(.reading):not(.no-rows) .reader { display: none; }
  .inbox-page .reading .folder { display: none; }
  .back { display: inline-flex; margin-bottom: .875rem; }
  .letter-label { display: none; }
  .letter { min-height: calc(100svh - 4rem); }
  .login-main { min-height: calc(100svh - 4rem); }
  .login-card { grid-template-columns: minmax(0, 1fr); max-width: 31rem; }
  .login-aside > p { margin: 0; }
  .login-aside > p br, .large-envelope { display: none; }
  .demo-credentials { margin-top: 1rem; }
}
