:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1e2428;
  --muted: #667078;
  --line: #dfe3e6;
  --accent: #176b5c;
  --accent-dark: #0f4f44;
  --error-bg: #fff1f0;
  --error-text: #912018;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

button,
.primary-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 9px 13px;
  text-decoration: none;
}

.time-toggle {
  background: #e9efed;
  color: var(--accent-dark);
  padding: 7px 10px;
}

button:hover,
.primary-link:hover {
  background: var(--accent-dark);
}

button.time-toggle:hover {
  background: #d7e4e0;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 22px;
}

.notice {
  margin-bottom: 16px;
  border: 1px solid #f1b5ad;
  border-radius: 6px;
  background: var(--error-bg);
  color: var(--error-text);
  padding: 12px 14px;
}

.auth-panel,
.empty {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.auth-panel h1,
.empty h1 {
  margin: 0 0 6px;
  font-size: 20px;
}

.auth-panel p,
.empty p {
  margin: 0 0 16px;
  color: var(--muted);
}

.inbox {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.email-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.email-row:last-child {
  border-bottom: 0;
}

.email-row:hover {
  background: #f1f6f4;
}

.email-row time {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.email-main {
  min-width: 0;
}

.email-line {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.sender {
  flex: 0 0 auto;
  max-width: 220px;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row p {
  margin: 4px 0 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
}

.message-nav {
  margin-bottom: 14px;
}

.message-nav a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.message h1 {
  margin: 0 0 18px;
  font-size: 28px;
  line-height: 1.2;
}

.meta {
  display: grid;
  gap: 8px;
  margin: 0 0 22px;
}

.meta div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
}

.meta dt {
  color: var(--muted);
  font-weight: 700;
}

.meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.attachments {
  margin: 0 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.attachments h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.attachments ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachments li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}

.attachments small {
  color: var(--muted);
  white-space: nowrap;
}

.message-body {
  overflow-wrap: anywhere;
}

.message-body img,
.message-body iframe,
.message-body script,
.message-body style {
  display: none !important;
}

.message-body table {
  max-width: 100%;
  border-collapse: collapse;
}

.message-body td,
.message-body th {
  border: 1px solid var(--line);
  padding: 6px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .status {
    justify-content: flex-start;
  }

  .page {
    padding: 14px;
  }

  .email-row {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 14px;
  }

  .email-line {
    flex-direction: column;
    gap: 2px;
  }

  .sender {
    max-width: 100%;
  }

  .message {
    padding: 18px;
  }

  .meta div {
    grid-template-columns: 1fr;
    gap: 1px;
  }
}
