/* doublezero-mail UI — same editorial system as the landing page */

:root {
  --bg: #ffffff;
  --ink: #0a0c10;
  --ink-2: #2a2f37;
  --muted: #6c7280;
  --line: #e6e8ec;
  --accent: #2962ff;       /* sky-blue tech accent (same family as landing) */
  --accent-fade: #e5edff;
  --red: #d92d20;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 12px 32px -16px rgba(10,12,16,.18);
  --radius: 8px;
  font-family: 'Helvetica Neue', Helvetica, 'Apple SD Gothic Neo', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'kern', 'liga';
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

[hidden] { display: none !important; }

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* When logged out, drop the sidebar and let the login fill the screen. */
body[data-auth="out"] #app { grid-template-columns: 1fr; }
body[data-auth="out"] .sidebar { display: none; }
body[data-auth="out"] .content { max-width: none; padding: 0; }
body[data-auth="out"] .login-gate { min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}
.brand-mark {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.brand-mark.big { width: 64px; height: 64px; }
.brand-word {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink-2);
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
}
.compose-btn:hover { background: var(--accent); }
.compose-btn span:first-child { font-size: 16px; line-height: 1; }

.tabs { display: flex; flex-direction: column; gap: 2px; }
.tab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
  color: var(--ink-2);
  font-size: 13px;
}
.tab:hover { background: var(--accent-fade); }
.tab.active { background: var(--ink); color: var(--bg); font-weight: 600; }
.tab.active .badge { background: var(--bg); color: var(--ink); }
.badge {
  background: var(--accent-fade);
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}

.account-block {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.account-block .name { color: var(--ink); font-weight: 600; }
.account-block .addr { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent); font-size: 11px; }

/* ── Content ─────────────────────────────────────────────────────── */
.content { padding: 24px 32px; max-width: 980px; }

h1, h2 { letter-spacing: -0.02em; margin: 0 0 16px; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Login */
.login-gate { display: grid; place-items: center; min-height: 80vh; }
.login-box {
  width: 360px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  text-align: center;
}
.login-box .brand-mark { margin: 0 auto 8px; }
.login-box input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}
.login-box input:focus { outline: 2px solid var(--accent); border-color: var(--accent); background: #fff; }
.login-box button {
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 600;
}

/* List */
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; }
.filters input, .filters select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
  font-size: 13px;
}

.list { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 24px 200px 1fr 80px;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  cursor: pointer;
  font-size: 13px;
}
.row:hover { background: var(--accent-fade); }
.row.unread { font-weight: 600; }
.row .star { font-size: 14px; color: var(--line); }
.row .star.on { color: #f5a524; }
.row .from { color: var(--ink); }
.row .subject { color: var(--ink-2); }
.row .subject .preview { color: var(--muted); margin-left: 6px; }
.row .date { color: var(--muted); font-size: 12px; text-align: right; }

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Detail */
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.detail-actions { display: flex; gap: 8px; }
.detail h2 { margin: 0 0 8px; font-size: 22px; }
.detail .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.detail .meta .dot { margin: 0 6px; }
.detail .body {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 16px 0;
}
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.atts a {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
}
.atts a:hover { border-color: var(--accent); color: var(--accent); }

/* Compose */
.compose-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.compose { display: flex; flex-direction: column; gap: 14px; }
.compose label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.compose label.readonly { color: var(--muted); }
.compose input, .compose textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
  font-size: 13px;
  color: var(--ink);
}
.compose input:focus, .compose textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); background: #fff; }
.compose textarea { font-family: inherit; resize: vertical; }
.compose .files ul { margin: 4px 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.compose .files li {
  font-size: 11px;
  color: var(--ink-2);
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.compose-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.settings label.readonly span { padding: 10px 12px; border-radius: 6px; background: #f5f7fa; font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent); }
.settings input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}
.settings input:focus { outline: 2px solid var(--accent); border-color: var(--accent); background: #fff; }

/* Teams */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.teams .card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.teams .card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.teams .card .name { font-weight: 600; }
.teams .card .addr { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--accent); }

/* Buttons */
button.primary {
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  align-self: flex-start;
}
button.primary:hover { background: var(--accent); }
button.ghost {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 12px;
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── Delivery status badges ───────────────────────────────────────── */
.badge-status {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  margin-right: 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.badge-sent       { background: #eef2f6; color: #6b7280; }
.badge-delivered  { background: #e6f4ea; color: #137333; }
.badge-bounced    { background: #fce8e6; color: #c5221f; }
.badge-complained { background: #fef7e0; color: #b06000; }
.badge-delayed    { background: #fff3e0; color: #c2410c; }
.status-line { margin: 4px 0 8px; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
  }
  .brand-word { display: none; }
  .tabs { flex-direction: row; }
  .account-block { margin-top: 0; border: none; }
  .content { padding: 16px; }
  .row { grid-template-columns: 24px 100px 1fr; }
  .row .date { display: none; }
}
