:root {
  --paper: #f3efe5;
  --paper-deep: #e8e1d2;
  --ink: #202523;
  --muted: #6f746f;
  --line: #d5cdbd;
  --green: #0f6c61;
  --green-deep: #08463f;
  --acid: #cddd4c;
  --orange: #d76539;
  --white: #fffdf8;
  --shadow: 0 18px 48px rgba(39, 47, 42, 0.12);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #d9d4c8;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body { height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 3% 4%, rgba(205, 221, 76, 0.38), transparent 24rem),
    #d9d4c8;
}

button,
a { -webkit-tap-highlight-color: transparent; }

button,
input { font: inherit; }

button { color: inherit; }

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: white;
  background: var(--green-deep);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.mail-shell {
  display: grid;
  grid-template-columns: 224px minmax(330px, 400px) minmax(440px, 1fr);
  width: min(1600px, calc(100% - 40px));
  height: calc(100dvh - 40px);
  min-height: 620px;
  margin: 20px auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(47, 54, 50, 0.22);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 28px 18px 20px;
  color: #f7f4ea;
  background:
    linear-gradient(145deg, transparent 48%, rgba(205, 221, 76, 0.08) 48.2%, transparent 48.6%),
    var(--green-deep);
}

.sidebar::after {
  position: absolute;
  right: -94px;
  bottom: 78px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(205, 221, 76, 0.23);
  border-radius: 50%;
  box-shadow: 0 0 0 25px rgba(205, 221, 76, 0.035), 0 0 0 52px rgba(205, 221, 76, 0.025);
  content: "";
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 8px 64px;
  letter-spacing: -0.02em;
}

.brand strong { display: block; font-size: 17px; }
.brand small { display: block; color: #aabdb2; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.brand-mark {
  display: grid;
  gap: 3px;
  width: 29px;
  height: 29px;
  padding: 6px 5px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
}

.brand-mark i { display: block; height: 1px; background: var(--acid); }
.brand-mark i:nth-child(2) { width: 65%; margin-left: auto; }

.folder-nav { display: grid; gap: 8px; }

.folder-link {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 10px 12px;
  color: #bdcbc3;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.folder-link:hover { color: white; transform: translateX(2px); }
.folder-link.is-active { color: white; background: rgba(255, 255, 255, 0.1); }
.folder-link.is-active .folder-icon { color: var(--green-deep); background: var(--acid); border-color: var(--acid); }

.folder-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  border: 1px solid #658079;
  border-radius: 4px 4px 6px 6px;
  font: 700 8px/1 "Courier New", monospace;
  letter-spacing: 0.08em;
}

.sidebar-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto 10px 4px;
  color: #d5dfd9;
  font: 12px/1.35 "Courier New", monospace;
}

.sidebar-note small { color: #839b91; }

.logout-button {
  margin: 14px 10px 0;
  padding: 8px 0;
  color: #aabdb2;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: 700 9px/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.logout-button:hover { color: white; }

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 4px rgba(205, 221, 76, 0.13);
}

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

.list-header {
  display: flex;
  min-height: 123px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 27px 25px 19px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font: 700 10px/1.2 "Courier New", monospace;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

.list-header h1 {
  margin: 0;
  font: 600 31px/1 Georgia, "Times New Roman", serif;
  letter-spacing: -0.03em;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  color: var(--green-deep);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: background 150ms ease, border 150ms ease, transform 150ms ease;
}

a.icon-button { text-decoration: none; }
.icon-button:hover { background: var(--white); border-color: #aca28e; transform: translateY(-1px); }
.icon-button:disabled { cursor: wait; opacity: 0.45; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.icon-button.is-active { color: #735b00; background: #f0dc78; border-color: #d2b843; }
.icon-button.is-active svg { fill: currentColor; }
.icon-button.is-loading svg { animation: spin 700ms linear infinite; }

.list-status {
  min-height: 31px;
  padding: 10px 25px 7px;
  color: var(--muted);
  border-bottom: 1px solid rgba(213, 205, 189, 0.65);
  font: 10px/1.4 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.message-row {
  position: relative;
  min-height: 111px;
  border-bottom: 1px solid var(--line);
  transition: background 130ms ease;
}

.message-row:hover { background: rgba(255, 253, 248, 0.65); }
.message-row.is-selected { background: var(--white); box-shadow: inset 3px 0 var(--green); }
.message-row.is-unread { background: #faf7ee; }

.message-open {
  display: flex;
  width: 100%;
  min-height: 110px;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 17px 52px 14px 25px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.message-row-top { display: flex; justify-content: space-between; gap: 12px; }
.message-row-top strong { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.is-unread .message-row-top strong { font-weight: 750; }
.message-row-top time { flex: 0 0 auto; color: var(--muted); font: 10px/1.5 "Courier New", monospace; }

.message-row-subject {
  overflow: hidden;
  color: #353a37;
  font: 17px/1.25 Georgia, "Times New Roman", serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-flags { display: flex; align-items: center; gap: 9px; color: #858980; font: 9px/1.2 "Courier New", monospace; text-transform: uppercase; }
.unread-dot { color: var(--green); }
.unread-dot::before { display: inline-block; width: 6px; height: 6px; margin-right: 5px; background: var(--green); border-radius: 50%; content: ""; }

.row-star {
  position: absolute;
  right: 17px;
  bottom: 16px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  color: #aaa698;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.row-star:hover { color: #806600; background: #eee6c3; }
.row-star.is-active { color: #927300; }
.row-star svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.row-star svg.is-filled { fill: currentColor; }

.load-more-wrap { padding: 8px; text-align: center; }

.text-button {
  padding: 8px 12px;
  color: var(--green);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
  font: 700 10px/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-button:disabled { opacity: 0.45; }

.reader-pane { position: relative; min-width: 0; overflow-y: auto; background: var(--white); }

.reader-pane::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 95px;
  height: 6px;
  background: var(--acid);
  content: "";
}

.reader-empty {
  display: grid;
  height: 100%;
  min-height: 500px;
  place-content: center;
  padding: 40px;
  text-align: center;
}

.reader-empty h2 { margin: 7px 0 9px; font: 500 32px/1.1 Georgia, "Times New Roman", serif; }
.reader-empty > p:last-child { max-width: 330px; margin: 0; color: var(--muted); line-height: 1.55; }

.empty-signal { display: flex; width: 78px; align-items: center; gap: 5px; margin: 0 auto 27px; }
.empty-signal span { display: block; width: 100%; height: 1px; background: var(--green); }
.empty-signal span:nth-child(2) { height: 8px; flex: 0 0 8px; background: var(--acid); border: 1px solid var(--green); border-radius: 50%; }

.reader-content { width: min(850px, 100%); margin: 0 auto; }

.reader-toolbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  min-height: 80px;
  align-items: center;
  justify-content: space-between;
  padding: 17px clamp(25px, 5vw, 64px);
  background: rgba(255, 253, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.reader-actions { display: flex; gap: 8px; margin-left: auto; }

.back-button {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 0;
  color: var(--green);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

.back-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; }

.message-heading { padding: 50px clamp(25px, 7vw, 72px) 31px; }

.message-heading h2 {
  max-width: 780px;
  margin: 8px 0 34px;
  font: 500 clamp(30px, 4vw, 48px)/1.08 Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

.sender-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 13px; }

.sender-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--white);
  background: var(--green);
  border-radius: 4px 50% 50%;
  font: 700 11px/1 "Courier New", monospace;
  letter-spacing: 0.06em;
}

.sender-copy { min-width: 0; }
.sender-copy > strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.address-toggle {
  display: flex;
  max-width: 100%;
  gap: 6px;
  padding: 2px 0;
  overflow: hidden;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 11px;
}

.address-toggle span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.address-toggle span:last-child { color: var(--green); font-weight: 800; }
.sender-row time { color: var(--muted); font: 10px/1.4 "Courier New", monospace; text-align: right; }

.address-details {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  margin-top: 8px;
  padding: 10px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 11px;
}

.address-details dt { color: var(--ink); font-weight: 700; }
.address-details dd { margin: 0; overflow-wrap: anywhere; }

.message-body { padding: 12px clamp(25px, 7vw, 72px) 48px; border-top: 1px solid var(--line); }
.html-message { display: block; width: 100%; min-height: 320px; border: 0; }

.plain-message {
  margin: 0;
  color: #282d2a;
  font: 16px/1.72 "Segoe UI", Arial, sans-serif;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.attachments { padding: 28px clamp(25px, 7vw, 72px) 60px; background: var(--paper); border-top: 1px solid var(--line); }
.attachments h3 { margin: 0 0 17px; font: 700 11px/1.2 "Courier New", monospace; letter-spacing: 0.09em; text-transform: uppercase; }
.attachment-list { display: grid; gap: 9px; }

.attachment-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
  transition: border 150ms ease, transform 150ms ease;
}

.attachment-card:hover { border-color: var(--green); transform: translateY(-1px); }
.attachment-card strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-card small { display: block; margin-top: 3px; color: var(--muted); font: 9px/1.2 "Courier New", monospace; }
.file-badge { display: grid; width: 44px; height: 38px; place-items: center; color: var(--green-deep); background: #dce7cd; border-radius: 4px; font: 700 9px/1 "Courier New", monospace; }
.download-label { color: var(--green); font: 700 9px/1 "Courier New", monospace; text-transform: uppercase; }

.reader-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 15px;
  color: var(--muted);
  background: var(--white);
  font: 10px/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.loading-orbit { width: 34px; height: 34px; margin: auto; border: 1px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 800ms linear infinite; }

.inline-error,
.list-error {
  margin: 15px 25px;
  padding: 15px;
  color: #772d1e;
  background: #f8e4db;
  border-left: 3px solid var(--orange);
  font-size: 13px;
  line-height: 1.5;
}

.list-error { margin-top: 30px; }
.list-error strong { display: block; }
.list-error p { margin: 5px 0 10px; }

.list-empty { display: grid; place-items: center; padding: 70px 25px; color: var(--muted); text-align: center; }
.list-empty strong { color: var(--ink); font: 500 20px/1.2 Georgia, "Times New Roman", serif; }
.list-empty p { max-width: 240px; margin: 7px 0; font-size: 13px; line-height: 1.5; }
.list-empty-mark { width: 38px; height: 26px; margin-bottom: 20px; border: 1px solid var(--green); border-radius: 3px 3px 8px 8px; box-shadow: inset 0 5px var(--acid); }

.skeleton-row { height: 111px; border-bottom: 1px solid var(--line); background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.65) 45%, transparent 60%) var(--paper-deep); background-size: 240% 100%; animation: shimmer 1.3s infinite; }

.auth-lock {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 25px;
  color: var(--white);
  background:
    linear-gradient(rgba(8, 70, 63, 0.92), rgba(8, 70, 63, 0.98)),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(205, 221, 76, 0.15) 40px);
}

.lock-card { width: min(470px, 100%); padding: clamp(30px, 7vw, 58px); background: #f7f2e7; color: var(--ink); border-top: 7px solid var(--acid); box-shadow: 16px 16px 0 rgba(2, 35, 31, 0.4); }
.lock-card h1 { margin: 10px 0 15px; font: 500 clamp(31px, 7vw, 46px)/1 Georgia, "Times New Roman", serif; letter-spacing: -0.04em; }
.lock-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.lock-glyph { display: block; width: 34px; height: 29px; margin-bottom: 30px; border: 2px solid var(--green); border-radius: 4px; box-shadow: inset 0 -19px var(--green); }
.lock-glyph::before { display: block; width: 16px; height: 15px; margin: -16px auto 0; border: 2px solid var(--green); border-bottom: 0; border-radius: 10px 10px 0 0; content: ""; }

.primary-button { margin-top: 15px; padding: 12px 18px; color: white; background: var(--green); border: 1px solid var(--green); border-radius: 3px; cursor: pointer; font: 700 11px/1 "Courier New", monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.primary-button:hover { background: var(--green-deep); }
.lock-card form { display: grid; gap: 10px; margin-top: 22px; }
.lock-card label { font: 700 10px/1 "Courier New", monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.lock-card input { width: 100%; padding: 12px 13px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 3px; }
.lock-card input:focus { outline: 3px solid var(--orange); outline-offset: 2px; }
.login-error { margin: 0; color: #8a2f1c; font-size: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -240% 0; } }

@media (max-width: 1050px) {
  .mail-shell { width: 100%; height: 100dvh; min-height: 560px; margin: 0; grid-template-columns: 190px minmax(310px, 360px) minmax(390px, 1fr); border: 0; border-radius: 0; }
  .brand { margin-bottom: 45px; }
  .sidebar { padding-inline: 13px; }
}

@media (max-width: 760px) {
  body { overflow: hidden; background: var(--paper); }
  .mail-shell { position: relative; display: block; min-height: 0; overflow: hidden; }

  .sidebar {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    height: 68px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    overflow: visible;
    background: var(--green-deep);
  }

  .sidebar::after,
  .brand,
  .sidebar-note,
  .logout-button { display: none; }
  .folder-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .folder-link { justify-content: center; gap: 7px; padding: 7px; font-size: 12px; }
  .folder-link:hover { transform: none; }
  .folder-icon { width: 25px; height: 21px; }

  .list-pane { height: calc(100dvh - 68px); border: 0; }
  .list-header { min-height: 98px; padding: 21px 20px 15px; }
  .list-header h1 { font-size: 28px; }
  .list-status { padding-inline: 20px; }
  .message-open { padding-left: 20px; }

  .reader-pane {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    background: var(--white);
    transform: translateX(102%);
    transition: transform 230ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .reader-open .reader-pane { transform: translateX(0); }
  .reader-empty { display: none; }
  .reader-content { min-height: 100%; }
  .reader-toolbar { min-height: 70px; padding: 12px 17px; }
  .back-button { display: flex; }
  .message-heading { padding: 34px 21px 25px; }
  .message-heading h2 { margin-bottom: 29px; font-size: clamp(29px, 9vw, 40px); }
  .message-body { padding: 10px 21px 40px; }
  .attachments { padding: 25px 21px 45px; }
  .sender-row { grid-template-columns: 39px minmax(0, 1fr); }
  .sender-avatar { width: 39px; height: 39px; }
  .sender-row time { grid-column: 2; margin-top: -8px; text-align: left; }
  .attachment-card { grid-template-columns: 40px minmax(0, 1fr); }
  .download-label { display: none; }
}

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