:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --border: #dfe5e2;
  --text: #1c2420;
  --muted: #5c6b64;
  --accent: #147a4c;
  --accent-ink: #ffffff;
  --warn: #9a6a00;
  --danger: #b3261e;
  --row-hover: #eef3f1;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101413;
    --surface: #1a201e;
    --border: #2e3835;
    --text: #e3eae7;
    --muted: #93a19a;
    --accent: #4cc38a;
    --accent-ink: #06281a;
    --warn: #e0a63c;
    --danger: #f2a49e;
    --row-hover: #232b29;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); }
.hidden { display: none !important; }

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand b { font-weight: 650; }
.brand svg { flex: none; }
.topbar nav { display: flex; gap: 2px; margin-left: 18px; }
.topbar nav button {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.topbar nav button:hover { background: var(--row-hover); color: var(--text); }
.topbar nav button.active { color: var(--text); font-weight: 600; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userbox .who {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* layout */
main { max-width: 1060px; margin: 0 auto; padding: 22px 20px 60px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 650; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* stats strip */
.stats { display: flex; gap: 0; flex-wrap: wrap; }
.stat { padding: 2px 26px 2px 0; margin-right: 26px; }
.stat + .stat { border-left: 1px solid var(--border); padding-left: 26px; }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }

/* table */
table.mail { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mail th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 12px; text-transform: none; letter-spacing: 0;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.mail td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.mail tbody tr { cursor: pointer; }
table.mail tbody tr:hover { background: var(--row-hover); }
table.mail tbody tr:last-child td { border-bottom: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.opened { background: var(--accent); }
.dot.unopened { background: #b9c2bf; }
.dot.off { background: var(--warn); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }

/* timeline */
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .kind {
  flex: none; width: 58px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.timeline .kind.open { color: var(--accent); }
.timeline .kind.click { color: var(--warn); }
.timeline time { flex: none; width: 150px; color: var(--muted); font-size: 12.5px; }
.timeline .url {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 12.5px;
}

/* forms */
label.f { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
input[type=text], input[type=password], input[type=email], textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 180px; resize: vertical; }
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(0.94); }
.btn.ghost {
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--border); }
.btn.small { padding: 5px 11px; font-size: 12.5px; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.error {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 9px 12px;
  margin: 12px 0;
  font-size: 13.5px;
}
.notice { color: var(--muted); font-size: 13px; margin: 10px 0; }

/* switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #b9c2bf; border-radius: 22px;
}
.slider:before {
  content: "";
  position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }
@media (prefers-reduced-motion: reduce) {
  .slider:before { transition: none; }
  * { transition: none !important; animation: none !important; }
}
.setting { display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.setting .txt b { display: block; font-size: 14px; }
.setting .txt span { color: var(--muted); font-size: 12.5px; }

/* opt-out list */
.optlist { list-style: none; margin: 10px 0; padding: 0; }
.optlist li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 2px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px;
}
.optlist li:last-child { border-bottom: 0; }

/* login */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-wrap .brand { justify-content: center; margin-bottom: 6px; font-size: 18px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
@media (max-width: 640px) {
  .topbar nav { margin-left: 4px; }
  .stat { padding-right: 14px; margin-right: 14px; }
  .stat + .stat { padding-left: 14px; }
  .timeline time { width: 110px; }
  table.mail .hide-sm { display: none; }
}
