:root {
  --ink: #18201d;
  --muted: #7a827e;
  --line: #e8ebe9;
  --soft: #f5f7f5;
  --paper: #ffffff;
  --accent: #315c4e;
  --accent-soft: #e7f0ec;
  --danger: #a74444;
  --shadow: 0 18px 50px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #eef1ee;
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(340px, 420px) minmax(440px, 1fr);
  width: 100%;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.accounts-panel {
  display: flex;
  flex-direction: column;
  background: #1f2925;
  color: #f6faf7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 30px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: #d7e9df;
  color: #28483d;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
}

.brand div,
.account-copy,
.sender-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand strong {
  font-family: Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.brand span:last-child,
.connection-note {
  color: #9daba5;
  font-size: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 10px 20px;
  color: #9daba5;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.accounts-panel .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.account-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px;
  overflow-y: auto;
}

.account-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 12px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease;
}

.account-item:hover,
.account-item.active {
  background: rgba(255, 255, 255, 0.09);
}

.account-avatar,
.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: #466158;
  color: white;
  font-weight: 700;
  text-transform: uppercase;
}

.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy span {
  color: #9daba5;
  font-size: 11px;
}

.unread-count {
  min-width: 23px;
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: #d7e9df;
  color: #25453a;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.accounts-footer {
  display: grid;
  gap: 10px;
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.connection-note {
  padding: 0 6px;
}

.refetch-all-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #f6faf7;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.refetch-all-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.refetch-all-button:disabled,
.refresh-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.messages-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fafbfa;
}

.messages-header,
.reader-header {
  border-bottom: 1px solid var(--line);
}

.messages-header {
  display: flex;
  min-height: 106px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

h1 {
  font-size: 25px;
}

h2 {
  max-width: 820px;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.18;
}

.refresh-button,
.images-button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  cursor: pointer;
}

.refresh-button {
  padding: 8px 11px;
  color: #59615d;
  font-size: 12px;
}

.refresh-button:hover,
.images-button:hover {
  border-color: #cdd5d1;
}

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

.message-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 17px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.message-item:hover {
  background: #f3f6f4;
}

.message-item.active {
  background: var(--accent-soft);
}

.message-item.unread::before {
  position: absolute;
  top: 25px;
  left: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.message-copy {
  min-width: 0;
}

.message-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.message-from,
.message-subject,
.message-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-from {
  margin-bottom: 2px;
  font-size: 13px;
}

.message-subject {
  font-size: 13px;
}

.message-preview,
.message-time {
  color: var(--muted);
  font-size: 11px;
}

.message-preview {
  margin-top: 3px;
}

.message-time {
  padding-top: 2px;
  white-space: nowrap;
}

.message-item.unread .message-from,
.message-item.unread .message-subject {
  font-weight: 750;
}

.reader-panel {
  position: relative;
  overflow-y: auto;
  background: var(--paper);
}

.reader-empty,
.empty-state {
  display: flex;
  height: 100%;
  min-height: 240px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--muted);
  text-align: center;
}

.reader-empty strong,
.empty-state strong {
  margin-bottom: 3px;
  color: #4b544f;
}

.reader-empty span,
.empty-state span {
  font-size: 12px;
}

.empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 13px;
  place-items: center;
  border-radius: 14px;
  background: var(--soft);
  color: var(--accent);
  font-size: 20px;
}

.reader-header {
  padding: clamp(28px, 5vw, 58px);
  padding-bottom: 25px;
}

.sender-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 28px;
}

.sender-details strong,
.sender-details span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-details span {
  color: var(--muted);
  font-size: 12px;
}

.images-button {
  margin-left: auto;
  padding: 7px 10px;
  color: var(--accent);
  font-size: 11px;
}

.reader-body {
  max-width: 900px;
  padding: 34px clamp(28px, 5vw, 58px) 70px;
  color: #303733;
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.reader-body img {
  max-width: 100%;
  height: auto;
}

.reader-body pre {
  white-space: pre-wrap;
  font: inherit;
}

.reader-body a {
  color: var(--accent);
}

.loading-row {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.error-state {
  margin: 20px;
  padding: 16px;
  border: 1px solid #edd6d6;
  border-radius: 10px;
  background: #fff7f7;
  color: var(--danger);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 9px;
  background: #18201d;
  color: white;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-header {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 220px 340px minmax(400px, 1fr);
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    position: relative;
    display: block;
    padding-top: 54px;
  }

  .mobile-header {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 5;
    display: flex;
    height: 54px;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
  }

  .mobile-header strong {
    font-family: Georgia, serif;
  }

  .panel {
    position: absolute;
    inset: 54px 0 0;
    width: 100%;
    height: calc(100% - 54px);
  }

  .accounts-panel,
  .messages-panel,
  .reader-panel {
    display: none;
  }

  .app-shell[data-mobile-view="accounts"] .accounts-panel {
    display: flex;
  }

  .app-shell[data-mobile-view="messages"] .messages-panel {
    display: flex;
  }

  .app-shell[data-mobile-view="reader"] .reader-panel {
    display: block;
  }

  .brand {
    padding-top: 20px;
  }

  .messages-header {
    min-height: 88px;
  }

  .reader-header {
    padding-top: 30px;
  }
}
