*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #161616;
  --border: rgba(255,255,255,0.07);
  --accent: #e8ff47;
  --accent2: #47c8ff;
  --danger: #ff5c5c;
  --text: #f0f0ee;
  --muted: #666660;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
}

a { color: inherit; }

/* Nav */
nav {
  position: sticky;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
}
.nav-logo {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-logo span { color: var(--accent); }
.nav-logo small {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-user {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.nav-links { display: flex; gap: 20px; list-style: none; align-items: center; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

/* Layout shell */
.shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
  border-radius: 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  padding: 11px 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.15s, border-color 0.2s;
}
.btn-primary { background: var(--accent); color: #0a0a0a; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 400; }
.btn-secondary:hover { border-color: rgba(255,255,255,0.25); transform: translateY(-1px); }
.btn-danger { background: transparent; border: 1px solid rgba(255,92,92,0.3); color: var(--danger); font-weight: 400; font-size: 12px; padding: 8px 16px; }
.btn-danger:hover { background: rgba(255,92,92,0.08); }

/* Login */
.login-wrap {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
}
.login-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 70% 30%, rgba(232,255,71,0.05) 0%, transparent 60%),
              radial-gradient(ellipse 40% 60% at 20% 80%, rgba(71,200,255,0.04) 0%, transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}
.login-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.login-eyebrow::before { content: ''; width: 22px; height: 1px; background: var(--accent); }
.login-card h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 8px;
}
.login-card h1 em { font-style: normal; color: var(--accent); }
.login-card .sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 32px;
}
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: border-color 0.2s;
}
.field input:focus { outline: none; border-color: rgba(232,255,71,0.4); }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 13px 20px; font-size: 14px; margin-top: 6px; }
.error-box {
  background: rgba(255,92,92,0.08);
  border: 1px solid rgba(255,92,92,0.25);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px 14px;
  border-radius: 4px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}
.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.page-header h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }

/* Message list */
.msg-list { display: flex; flex-direction: column; gap: 2px; }
.msg-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 20px minmax(0,220px) 1fr auto;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.msg-row:hover { background: var(--surface2); border-color: rgba(255,255,255,0.12); }
.msg-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.msg-row.unread .msg-dot { background: var(--accent); }
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { font-weight: 700; }
.msg-from { font-family: var(--font-mono); font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.unread .msg-from { color: var(--text); }
.msg-subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.msg-empty {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 13px;
  padding: 60px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

/* Message view */
.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 32px;
}
.msg-card .msg-meta { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 24px; }
.msg-card h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 14px; }
.msg-meta-row { font-family: var(--font-mono); font-size: 12px; color: var(--muted); line-height: 1.8; }
.msg-meta-row strong { color: var(--text); font-weight: 400; }
.msg-body { font-family: var(--font-mono); font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-wrap: break-word; }
.msg-actions { display: flex; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* Compose */
.compose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 32px;
}
.compose-card textarea {
  width: 100%;
  min-height: 260px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
}
.compose-card textarea:focus, .compose-card input:focus { outline: none; border-color: rgba(232,255,71,0.4); }
.compose-actions { display: flex; gap: 10px; margin-top: 20px; }
.flash-ok {
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25);
  color: #4ade80;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px 14px;
  border-radius: 4px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  nav { padding: 14px 20px; }
  .shell { padding: 32px 16px 60px; }
  .msg-row { grid-template-columns: 14px 1fr; grid-template-areas: "dot from" "dot subject" "dot date"; row-gap: 4px; }
  .msg-dot { grid-area: dot; }
  .msg-from { grid-area: from; white-space: normal; }
  .msg-subject { grid-area: subject; white-space: normal; }
  .msg-date { grid-area: date; }
  .login-card { padding: 32px 24px; }
}
