:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --bg-hover: #1c2430;
  --border: #2d333b;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #4dabf7;
  --accent-2: #9775fa;
  --danger: #f47272;
  --ok: #3fb950;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 22px;
}

.address-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

#address {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 15px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #26303e; border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

.status { display: flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.dot.live { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.down { background: var(--danger); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

#list-pane {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  background: var(--bg);
}

.count {
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 1px 9px;
  font-size: 12px;
}

#message-list { list-style: none; margin: 0; padding: 0; }

#message-list li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
#message-list li:hover { background: var(--bg-hover); }
#message-list li.selected { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--accent); }
#message-list li.unread .m-subject { font-weight: 700; }

.m-subject {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-from {
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.m-snippet {
  color: var(--text-dim);
  font-size: 13px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-dim); margin-top: 3px; }

#viewer-pane { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }

.viewer-head { padding: 20px 26px 14px; border-bottom: 1px solid var(--border); }
.viewer-head h2 { margin: 0 0 8px; font-size: 20px; }
.viewer-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 13px;
}
#v-from { color: var(--accent); }
.expires { color: var(--danger); }

.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.attachments a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.attachments a:hover { border-color: var(--accent); }

.viewer-body { flex: 1; padding: 0; display: flex; min-height: 400px; }
.viewer-body iframe {
  flex: 1;
  border: 0;
  background: #fff;
  min-height: 400px;
}
.viewer-body pre {
  flex: 1;
  margin: 0;
  padding: 22px 26px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.6 ui-monospace, "Cascadia Code", Menlo, monospace;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-align: center;
  padding: 40px 20px;
  gap: 4px;
}
.empty p { margin: 2px 0; }
.empty-icon { font-size: 42px; }
.hint { font-size: 13px; max-width: 240px; }

footer {
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

.footer-links { margin-left: 10px; }
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--accent); }

.ad-slot {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}
.ad-slot:empty { display: none; }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  z-index: 10;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }
  #list-pane { border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; }
}
