:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1d222c;
  --border: #2a3140;
  --text: #e6eaf2;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-2: #6aa2ff;
  --unread: #ffb74d;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#app { height: 100%; }

/* ─── login ─── */
.login-shell {
  height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 50% 0%, #1a2030 0%, var(--bg) 70%);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  width: 360px;
  max-width: calc(100vw - 32px);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.muted { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.login-card button {
  margin-top: 12px;
  width: 100%;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-2); }
.login-card .err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ─── inbox shell ─── */
.shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar header .title { font-weight: 600; }
.sidebar header button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.sidebar header button:hover { color: var(--text); }
.threads { overflow-y: auto; flex: 1; }
.thread {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.thread:hover { background: var(--panel-2); }
.thread.active { background: var(--panel-2); border-left: 3px solid var(--accent); padding-left: 13px; }
.thread .row { display: flex; justify-content: space-between; gap: 8px; }
.thread .from { font-weight: 600; font-size: 13px; }
.thread.unread .from { color: var(--unread); }
.thread .when { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.thread .subject { font-size: 13px; margin-top: 2px; }
.thread .preview { color: var(--muted); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .badge {
  display: inline-block;
  background: var(--unread);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

/* ─── pane ─── */
.pane { display: flex; flex-direction: column; min-height: 0; }
.pane-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}
.pane-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.pane-header h2 { margin: 0; font-size: 16px; }
.pane-header .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.messages { flex: 1; overflow-y: auto; padding: 16px 20px; }
.msg {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.msg.out { background: #18221a; border-color: #2a3a2c; }
.msg .head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.msg .who strong { color: var(--text); }
.msg pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font: inherit; }

/* ─── reply ─── */
.reply {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  background: var(--panel);
}
.reply textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.reply .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.reply .hint { color: var(--muted); font-size: 12px; }
.reply button {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.reply button:disabled { opacity: 0.5; cursor: not-allowed; }
.reply button:hover:not(:disabled) { background: var(--accent-2); }
.reply .err { color: var(--danger); font-size: 12px; margin-top: 6px; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: var(--mobile-sidebar, flex); }
  .pane { display: var(--mobile-pane, none); }
}
